Bug 1838598 - Nyx: Adjust replay format. r=truber

Differential Revision: https://phabricator.services.mozilla.com/D181057
This commit is contained in:
Christian Holler (:decoder) 2023-06-20 19:51:47 +00:00
Родитель 157e74a7f7
Коммит 0071128928
1 изменённых файлов: 5 добавлений и 18 удалений

Просмотреть файл

@ -67,31 +67,18 @@ void Nyx::start(void) {
std::ifstream is; std::ifstream is;
is.open(testFile, std::ios::binary); is.open(testFile, std::ios::binary);
uint64_t chksum, num_ops, num_data, op_offset, data_offset;
// If only C++ supported streaming operators on binary files...
is.read(reinterpret_cast<char*>(&chksum), sizeof(uint64_t));
is.read(reinterpret_cast<char*>(&num_ops), sizeof(uint64_t));
is.read(reinterpret_cast<char*>(&num_data), sizeof(uint64_t));
is.read(reinterpret_cast<char*>(&op_offset), sizeof(uint64_t));
is.read(reinterpret_cast<char*>(&data_offset), sizeof(uint64_t));
if (!is.good()) {
MOZ_FUZZING_NYX_PRINT("[Replay Mode] Error reading input file.\n");
_exit(1);
}
is.seekg(data_offset);
// The data chunks we receive through Nyx are stored in the data // The data chunks we receive through Nyx are stored in the data
// section of the testfile as chunks prefixed with a 16-bit data // section of the testfile as chunks prefixed with a 16-bit data
// length. We read all chunks and store them away to simulate how // length that we mask down to 11-bit. We read all chunks and
// we originally received the data via Nyx. // store them away to simulate how we originally received the data
// via Nyx.
while (is.good()) { while (is.good()) {
uint16_t pktsize; uint16_t pktsize;
is.read(reinterpret_cast<char*>(&pktsize), sizeof(uint16_t)); is.read(reinterpret_cast<char*>(&pktsize), sizeof(uint16_t));
pktsize &= 0x7ff;
if (!is.good()) { if (!is.good()) {
break; break;
} }