summaryrefslogtreecommitdiff
path: root/netdissect.c
Commit message (Collapse)AuthorAgeFilesLines
* Add some const qualifiersFrancois-Xavier Le Bail2022-04-021-3/+3
|
* Fix a typoFrancois-Xavier Le Bail2022-04-021-2/+2
| | | | | | | Moreover: Fix indentation. [skip ci]
* Have routines that set the snapend take a buffer pointer and length as args.Guy Harris2022-03-311-48/+68
| | | | | | | | | | | | | | | | | | | | | | | | Have nd_push_buffer() take a snapshot length, not a snapshot end, as its last argument. Replace nd_push_snapend() and nd_change_snapend() with nd_push_snaplen() and nd_change_snaplen(), both of which take a pointer into the packet buffer and snapshot length relative to that pointer as arguments. Have those routines check the snapshot length to make sure it's not bigger than the number of bytes in the packet past the pointer, and silently ignore the requst if it is. Using a length rather than a pointer avoids the possibility of the calculation of the snapshot end overflowing and resulting in a snapshot end *before* the point in the buffer. Add a test for this, with a capture file containing an IPv6 packet with an extremely large "jumbo" packet size. Revert the "Make sure we don't set the snapend before the beginning of the packet." changes, as they no longer apply with this change (which also makes sure we don't set the snapend before the beginning of the packet).
* Make sure we don't set the snapend before the beginning of the packet.Guy Harris2022-03-291-8/+53
| | | | | | | | | | | If a caller attempts to set it after the current snapend, just silently ignore the attempt. If they try to set it before the beginning of the packet, report it as a bug and quit dissection. Add a new setjmp() return value meaning "bug" rather than "truncated packet", add an "nd_bug_longjmp()" routine for reporting bugs where we should quit dissecting, and use that in this case.
* Remove more old-compiler compensation.Guy Harris2019-08-081-2/+2
| | | | | | | | | | | | We require an environment with a C99-compatible snprintf(), so we don't need to work around older implementations. Make the configuration process fail if we don't have snprintf() and vsnprintf(). We require at least VS 2015, so we don't have to check for _MSC_VER >= 1400. Make the build fail if we don't have at least VS 2015. We apparently do, however, have to use __inline, as the VS 2015 documentation doesn't meaning plain old "inline". Update a comment.
* Handle the IPv6 Jumbo Payload option.Guy Harris2019-05-021-0/+21
| | | | | | | | | If we see one when processing the hop-by-hop extension header, use it to set the payload length. In UDP, if we have a zero length field in the UDP header, and the length of the data handed to us is > 65535, treat that as a Jumbo Payload packet.
* Treat the length field in an Ethernet header as such.Guy Harris2019-04-221-19/+44
| | | | | | | | | | | | | | If we have an Ethernet packet where the last 2 octets of the header are a length rather than an Ethernet type, and it's less than the remaining length of the packet, shorten the length and captured length, update the snapshot end. Turn the buffer stack into a "packet information" stack, so that, if we *do* update the snapshot end, we push the old end onto the stack, and pop it off as soon as we're done dissecting the Ethernet packet, in case there's more data in the packet after the Ethernet packet. Use the stack when we use the IPv4 and IPv6 length fields as well.
* Fix some warningsFrancois-Xavier Le Bail2019-03-311-0/+1
| | | | | | | | The warnings were: implicit declaration of function 'malloc' [-Wimplicit-function-declaration] incompatible implicit declaration of built-in function 'malloc' implicit declaration of function 'free' [-Wimplicit-function-declaration] incompatible implicit declaration of built-in function 'free'
* Introduce a buffer stack, and use it for ESP decryption.Guy Harris2019-03-301-0/+43
| | | | | | | | | | | | | | | If a dissector has to process its input - decryption, decompression, etc. - rather than dissect the raw input, it should push the processed input onto the buffer stack. As soon as the dissection is done, the stack should be popped, to free the buffer into which the processing was done, and restore the "pointer to packet data" and "pointer to end of packet data" members of the netdissect_options structure, so the code can go back to dissecting the original data. The stack will get everything popped off it when dissection is done. Use this mechanism in the ESP decryption code rather than scribbling on top of the input packet data.
* Add nd_{v}snprintf() routines/wrappers.Guy Harris2018-01-291-2/+2
| | | | | | | | Some versions of the MSVC runtime library have a non-C99-compliant vsnprintf(), which we want to avoid. On Windows, use snprintf() and vsnprintf() for VS 2015 and later, where they both exist in C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're guaranteed to do the null termination that we want).
* Always include <config.h> rather than "config.h".Guy Harris2018-01-211-1/+1
| | | | | | | | This can prevent bizarre failures if, for example, you've done a configuration in the top-level source directory, leaving behind one config.h file, and then do an out-of-tree build in another directory, with different configuration options. This way, we always pick up the same config.h, in the build directory.
* Use quoted include netdissect-stdinc.h instead of angle-bracketed oneFrancois-Xavier Le Bail2018-01-211-1/+1
|
* Use strlcpy(), rather than snprintf(), to avoid null format string warnings.Guy Harris2016-08-061-2/+3
| | | | Include the appropriate headers to declare strlcpy() and snprintf().
* add a missing declaration in netdissect.cGisle Vanem2016-08-061-0/+1
|
* Move more libsmi stuff to netdissect.c.Guy Harris2016-08-041-0/+44
| | | | | | | | | | | | | | Have the call to smiLoadModule() be in a nd_load_smi_module() routine. Have it set a *global* flag indicating whether a module has been loaded; that's not per-netdissect_options. Use that global flag in print-snmp.c - and don't test it once per loop iteration, it's not going to change while the loop is running. Have a routine to return the version of the library if we're built with it or NULL if we're not. That removes the last of the code that tests USE_LIBSMI or uses libsmi from tcpdump.c.
* Add netdissect.c.Guy Harris2016-08-041-0/+100