rvelea / LightPcapNg

PcapNg read, write and manipulation API.
MIT License
29 stars 19 forks source link

Invalid section block size and interface block size #8

Open exuvo opened 8 months ago

exuvo commented 8 months ago

I am calling light_pcapng_open_write(file, light_create_default_file_info()) and light_pcapng_open_write is writing a section header that is 12 bytes too large and also appending 12 bytes too large interface description blocks. This file then fails to open in both light_pcapng_open_append and wireshark as they think that extra space is for options.

https://github.com/rvelea/LightPcapNg/blob/33296580096f83a9f17ebe7ea3d2c79977a24471/src/light_pcapng_ext.c#L215 https://github.com/rvelea/LightPcapNg/blob/33296580096f83a9f17ebe7ea3d2c79977a24471/src/light_pcapng_ext.c#L250 +3*sizeof(uint32_t) is the extra incorrect values you are adding to the block size. light_alloc_block does the same inside for the block_total_length, which is correct, so i think you are just appending it twice for some reason? Removing the outside +3* solves it.

I can then open the written file with both light_pcapng_open_append and wireshark without errors. I suggest you check your tests too as such an obvious thing should not have been passing them?

exuvo commented 8 months ago

Same problem in light_write_packet