For BGP, this eliminates some cases where routines return -1 on
truncation; clean up after that.
This also means that some memcpy()s get replaced by UNALIGNED_MEMCPY(),
which may fix some issues on processors that don't support unaligned
accesses.
They are redundant because they are followed by a GET_IPADDR_STRING(e)
call, same e, which do the bounds check.
Remove unused 'trunc' label(s) and associated code(s).
Remove a number of instances that do not match common patterns and have
the only substantial effect on the code flow that a truncated packet
triggers "goto trunc" instead of longjmp(). (In a few cases this change
can increase the number of fields printed before giving up.)
They are redundant because they are followed by a GET_IP6ADDR_STRING(e)
call, same e, which do the bounds check.
Remove unused 'trunc' label(s) and associated code(s).
ND_TCHECK_n(e), n in { 1, 2, 3, 4, 8 }.
They are redundant because they are followed by a GET_.*_n(e) call,
same n, same e, which do the bounds check.
Remove unused 'trunc' labels and most associated codes.
Update the outputs of some tests accordingly.
Using ND_TTEST_LEN() makes the check a bit more stringent.
Using ND_BYTES_BETWEEN() casts the difference to a u_int, so it's 1)
unsigned and 2) not 64-bit on LP64 or LLP64 platforms.
Adapted from GitHub pull request #798.
Print " (invalid)" when combinations of V-Flag and L-Flag are invalid.
Update comments (draft -> RFC).
Remove some ND_TCHECK_LEN because GET_ use.
Update the output of isis_sid test because commit
b09710dfcd updated the output format
of the IS-IS dissector.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.
Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.
Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
The error were like:
print-isoclns.c:2583:20: runtime error: unsigned integer overflow:
20 - 27 cannot be represented in type 'unsigned int'
print-isoclns.c:2525:20: runtime error: unsigned integer overflow:
0 - 20 cannot be represented in type 'unsigned int'
Update the output of two tests accordingly.
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.
Do more checks for running past the TLV or subTLV length.
For errors where we go past the TLV or subTLV length, report that as a
separate error from just "ran past the end of the packet".
When looping over TLVs or subTLVs, loop as long as there's data
available and, if there isn't *enough* data available within the TLV or
subTLV, report that as a "ran past the end of the TLV/subTLV" error.
In isis_print_ext_is_reach(), correctly calculate the number of bytes we
process - that amount is smaller for the Alias TLV than for other TLVs,
as the Alias TLV doesn't have a Metric field.
Same bugfixes than in previous commit, based on a code inspection.
Update the output of a test accordingly.
Moreover:
Clean up whitespaces/indentation.
The error was:
print-isoclns.c:2822:7: runtime error: unsigned integer overflow:
4 - 6 cannot be represented in type 'unsigned int'
Update the output of a test accordingly.
Moreover:
Clean up whitespaces/indentation.
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
Cast pointer differences, widen some variables, make some function
returns unsigned as they never return a negative number.
Fix a format while we're at it.
See also commit f944e1e39.
[print-isoclns.c:906] -> [print-isoclns.c:910]: (warning) Opposite inner
'if' condition leads to a dead code block.
[skip ci]
This change addresses one of the warnings listed in the bug report.
./print-isoclns.c: In function ‘clnp_print’:
./print-isoclns.c:1054:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (EXTRACT_U_1(pptr) == NLPID_CLNP) {
^
./print-isoclns.c:1061:9: note: here
case CLNP_PDU_DT:
^~~~
[skip ci]
The functions are: nd_print, nd_printztn, nd_printn and nd_printzp.
Trying to make it clearer that they currently have to be used only on part
of the packet buffer.
Update some comments.