-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pcapng Clarification question - is end of option need to be when there are no options #108
Comments
If we have to write code that deals with the lack of an end of option, maybe we should just obsolete opt_endofopt? |
I agree, I don't see additional value added to that option |
That's because there is none. At least for all existing blocks that support options, the options are at the end of the block, so the end of the options occurs when you run out of remaining data in the block, and there's no need for an end-of-options marker. Furthermore, the spec explicitly says that all blocks must be structured that way:
The spec says
The intent behind
is to keep readers from doing something blatantly stupid such as running past the end of the block if the writer didn't put an end-of-option marker in the block. The intent behind
is to avoid having readers that would do something blatantly stupid such as running past the end of the block if the writer didn't put an end-of-option marker in the block actually do something stupid. "Belt and suspenders", as the saying goes. At least some software that writes blocks does not add an end-of-option marker if there are no options in the first place. For example, neither Wireshark nor the pcapng-writing code in the macOS libpcap does so. As such, it may be that, when reading a block with no options, some blatantly stupid code might well process the non-existent options until it either 1) gets a SIGSEGV, 2) scribbles on memory (by byte-swapping in place) that causes sufficient damage to cause a crash, or 3) hits a random blob of memory with 4 bytes of zero so that it looks like an end-of-option marker. However, there might be other code that's careful enough to find out how many bytes of option there are (which is enough information to prevent that form of blatant stupidity) but not careful enough to do anything with it other than
and then, in So perhaps what we should do is change
to
We'll continue to write it in Wireshark, at least for now, if any options are present. If any pcapng-writing code is added to libpcap, should it write it, or is it time to flush out blatantly stupid code, and not put that into libpcap and eventually remove it from Wireshark? EDIT: Fixed 2023-01-22 to say "is to avoid having readers that would do something blatantly stupid such as running past the end of the block if the writer didn't put an end-of-option marker in the block actually do something stupid" rather than "is to avoid having writers that would do something blatantly stupid such as running past the end of the block if the writer didn't put an end-of-option marker in the block actually do something stupid". |
Wow @guyharris, very comprehensive explanation. After what you said, I don't think you should remove the end of options option if the option list isn't empty as it could potentially break parsing libraries that assume it exist. |
If the option list is empty does code that writes pcapng files MUST put an
opt_endofopt
anyway?The text was updated successfully, but these errors were encountered: