Commit Graph

303 Commits

Author SHA1 Message Date
Denis Ovsienko
032d569e68 Spell "indent" where it belongs. 2021-03-28 13:44:35 +01:00
Guy Harris
f853e73acf Replace ND_TCHECK_/memcpy() pairs with GET_CPY_BYTES().
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.
2021-01-05 18:08:50 -08:00
Francois-Xavier Le Bail
42c0601fcf ISIS: Replace the 'if (nd_printzp()) goto trunc' by nd_printjnp() calls
Moreover:
Use the sizeof operator.
2020-12-10 21:43:48 +01:00
Denis Ovsienko
4963b2e138 Use MAC_ADDR_LEN in a few more places. [skip ci] 2020-09-19 02:07:16 +01:00
Denis Ovsienko
2bfa05b9b6 Remove 7 more ND_TCHECK calls. 2020-09-08 16:23:56 +01:00
Francois-Xavier Le Bail
3b8ff4bf0d Remove some now redundant ND_TCHECK_LEN(e, sizeof(nd_ipv4)) calls
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).
2020-09-08 14:35:21 +02:00
Denis Ovsienko
51e180c4fb Remove 96 assorted ND_TCHECK calls.
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.)
2020-09-08 05:04:58 +01:00
Francois-Xavier Le Bail
24df77f09e Remove some now redundant ND_TCHECK_LEN(e, sizeof(nd_ipv6)) calls
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).
2020-09-07 23:03:09 +02:00
Francois-Xavier Le Bail
abc8c2d61c Remove many (762) now redundant ND_TCHECK_n() calls
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.
2020-09-06 20:22:29 +02:00
Guy Harris
228f225ca0 esis: explain why we're doing ND_TTEST_LEN(pptr, 1). 2020-05-27 02:28:20 -07:00
Guy Harris
a225ce337d isis: add some additional length checks.
Make sure the length in question is big enough before fetching data and
subtracting from it.
2020-05-26 22:14:24 -07:00
Guy Harris
3cb1082cb5 esis: use ND_TTEST_LEN() and ND_BYTES_BETWEEN() on pointers.
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.
2020-05-26 22:13:02 -07:00
Guy Harris
ae251eb4a4 clnp: use ND_BYTES_BETWEEN() to get the bytes between two packet pointers.
That'll cast it to a u_int, so it's 1) unsigned and 2) not 64-bit on
LP64 or LLP64 platforms.
2020-05-26 22:09:11 -07:00
ckishimo
586e9b7720 IS-IS: Add LAN Adjacency Segment Identifier subTLV
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.
2020-05-25 16:43:42 +02:00
Hannes Gredler
b09710dfcd IS-IS: Add support for Node/Prefix SIDs as per rfc 8667
(pull request #845)
2020-04-07 10:42:19 +02:00
Manoharan Sundaramoorthy
4157af94f2 Parse the IS-IS Instance Identifier TLV from RFC8202 2020-02-21 04:45:24 -08:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
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.
2020-01-19 19:55:38 -08:00
Francois-Xavier Le Bail
da5ac63504 IS-IS: Use %zu to print sizeof values 2019-11-09 11:33:34 +01:00
Francois-Xavier Le Bail
a7a34cc483 IS-IS: Fix some undefined behaviors at runtime
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.
2019-11-08 21:41:47 +01:00
Francois-Xavier Le Bail
0ec7203f8c Cleaning spaces
[skip ci]
2019-11-07 09:24:09 +01:00
ckishimo
d9ed02212a add isis router capability TLV 2019-09-04 20:26:44 +02:00
Francois-Xavier Le Bail
8534f3b7bf Use more HTTPS in URLs
[skip ci]
2019-08-19 15:49:21 +02:00
Guy Harris
b1e5f800b3 More use of %zu to print sizeof values. 2019-08-11 12:23:36 -07:00
Guy Harris
1ed63b5d06 Remove more old-compiler compensation.
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.
2019-08-08 23:21:35 -07:00
Francois-Xavier Le Bail
7217abf41a Use nd_print_protocol_caps() to print the protocol name in caps 2019-06-23 14:22:19 +02:00
Francois-Xavier Le Bail
20eab47a4d Fix trailing spaces 2019-05-23 11:16:47 +02:00
Guy Harris
0fa0692de3 Clean up TLV processing.
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.
2019-05-14 01:23:24 -07:00
Guy Harris
dc9744f7c6 Squelch more warnings. 2019-04-17 20:21:53 -07:00
Guy Harris
bef667db65 Clean up types to squelch narrowing warnings. 2019-04-17 19:53:00 -07:00
Francois-Xavier Le Bail
0610a7cff2 IS-IS: Simplify some expressions 2019-04-09 22:50:41 +02:00
Francois-Xavier Le Bail
eafdbf764b ISOCLNS: Replace printf by ND_PRINT even when "#if 0"ed-out 2019-04-09 09:20:09 +02:00
Francois-Xavier Le Bail
c36abfe8a8 IS-IS: Fix some loops for undefined behavior at runtime
Same bugfixes than in previous commit, based on a code inspection.

Update the output of a test accordingly.

Moreover:
Clean up whitespaces/indentation.
2019-04-08 19:36:13 +02:00
Francois-Xavier Le Bail
fed13fc486 IS-IS: Fix a loop for undefined behavior at runtime
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.
2019-04-08 17:23:53 +02:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
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.
2019-03-26 21:06:24 +01:00
Francois-Xavier Le Bail
1af20c3adc Add the ndo parameter to some functions
This parameter will be needed at the next step.
2019-03-26 21:06:23 +01:00
Francois-Xavier Le Bail
2f6c710131 IS-IS: Fix inaccurate variable names 2019-03-10 23:17:58 +01:00
Francois-Xavier Le Bail
0f9808547c Clean up whitespaces/indentation 2019-02-27 21:24:12 +01:00
Francois-Xavier Le Bail
a67cf88e5d IS-IS: Replace some ND_TTEST_*() calls with ND_TCHECK_*() calls 2019-02-25 17:40:02 +01:00
Antonin Décimo
0b3880c91e Fix small misspellings 2019-01-23 17:28:14 +01:00
Guy Harris
1dbc62cb83 Clean up some narrowing warnings.
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.
2018-09-23 18:09:56 -07:00
Guy Harris
ccd4a6b3b9 Fix the variable for the packet length.
The length passed in is a u_int, so we should assign it to a u_int, not
a u_short.
2018-09-23 18:02:37 -07:00
Francois-Xavier Le Bail
77a49fcb6e Add the nd_print_invalid() function
It prints " (invalid)", used for malformed or corrupted packets.

Moreover:
Update CONTRIBUTING.
2018-09-11 13:09:05 +02:00
Denis Ovsienko
3ee05fb6ce CLNP: Squelch a cppcheck warning (GH #629)
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]
2018-07-30 14:08:03 +01:00
Denis Ovsienko
eebb3f48e3 CLNP: squelch a fall-through warning (GH #618)
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]
2018-07-26 13:16:11 +01:00
Francois-Xavier Le Bail
74d0778d0c ES-IS,IS-IS: Add two missing return
Update the output of some tests accordingly.
2018-05-25 17:12:45 +02:00
Francois-Xavier Le Bail
6e1fdd00a6 Add a nd_print_trunc() call
Replace a ND_TTEST_*() with ND_TCHECK_*().
Update the output of some tests accordingly.
2018-05-18 14:58:38 +02:00
Francois-Xavier Le Bail
ba8936b39b Print truncations with nd_print_trunc() instead of tstr[] strings
Remove the tstr[] strings.
Update the output of some tests accordingly.

Moreover:
Add or update some ndo_protocol fields.
2018-05-04 13:47:49 +02:00
Francois-Xavier Le Bail
3e3e6d2ef4 Rename the fn_printX() functions to nd_printX()
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.
2018-04-30 13:35:06 +02:00
Francois-Xavier Le Bail
56e6581c34 Remove useless comments 2018-03-19 15:16:32 +01:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00