IETF-OPSAWG-WG / draft-ietf-opsawg-pcap

PCAP next generation file format specification
Other
267 stars 62 forks source link

Is extraneous padding legal? #26

Open hadrielk opened 9 years ago

hadrielk commented 9 years ago

Is it legal to use more than 4 bytes of padding?

For example: if the file has a SPB, with an original packet length of 1000 but an IDB snaplen of 120, and the SPB's Block Length is 144 (=12 bytes Block headers + 4 bytes SPB packet length, leaving 128 bytes of packet data)... is that valid?

Another example is option strings - we don't always specify if they're null-terminated or not, and if an app decides to encode the null it may force them to have to add padding they wouldn't have to have without the null; so if a reader app does not expect the null, it will think there are 4 extra (unnecessary) padding bytes. Edit: that doesn't cause a problem, because the option length will include that NULL.

hadrielk commented 9 years ago

I think the answer to this is no, extra padding bytes are not legal. The reason is you can't distinguish the extra padding bytes from an opt_endofopt option. Well... you could realize the Block Length is longer, and keep looking for a non-zero option code in the remaining bytes I guess... but it would be annoying and likely error prone.