Skip to content

Commit 5b3c446

Browse files
committed
Fix vuln OSV-2023-1147
1 parent f81ced2 commit 5b3c446

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void light_read_record(light_file fd, light_pcapng *record)
329329
assert((current->block_total_length % 4) == 0);
330330

331331
//Pull out the block contents from the file
332-
const uint32_t bytesToRead = current->block_total_length - 2 * sizeof(blockSize) - sizeof(blockType);
332+
const uint32_t bytesToRead = current->block_total_length - 2 * sizeof(blockSize) - sizeof(blockType) + 2 * sizeof(uint32_t);
333333
uint32_t *local_data = calloc(bytesToRead, 1);
334334
bytesRead = light_read(fd, local_data, bytesToRead);
335335
if (bytesRead != bytesToRead || (bytesRead == EOF && feof(fd->file)))
@@ -355,7 +355,7 @@ void light_read_record(light_file fd, light_pcapng *record)
355355
//So we just cheat by decrementing the data pointer back 8 bytes;
356356
parse_by_block_type(current, local_data, local_data - 2);
357357

358-
free(local_data);
358+
free(local_data - 2);
359359
*record = current;
360360

361361
return;

0 commit comments

Comments
 (0)