diff options
author | Denis Ovsienko <denis@ovsienko.info> | 2020-09-16 01:38:07 +0100 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2020-09-16 01:38:07 +0100 |
commit | 503c7d1dc16961fdd8a3f62aea688cab270328e9 (patch) | |
tree | 27dda3be500f5d881fdfd8ec46cf3c380b5ee59c | |
parent | 0a5faecf953a8a997b0e90e0bed1d763542166e0 (diff) | |
download | tcpdump-503c7d1dc16961fdd8a3f62aea688cab270328e9.tar.gz |
OpenFlow 1.0: Lose 7 ND_TCHECK_LEN() calls.
Considering a protocol field that has a known size and contains a
zero-padded string, in a code of this particular form:
ND_TCHECK_LEN(field_start, field_length);
nd_print(ndo, field_start, field_start + field_length);
...the only effect of the ND_TCHECK_LEN() call is that when the protocol
field is not entirely within the packet buffer, the code before
triggering a longjmp() prints nothing instead of printing the part of
the field that is within the packet buffer. Thus remove these instances
of ND_TCHECK_LEN(), so the output better represents the captured data.
-rw-r--r-- | print-openflow-1.0.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index db1119bd..1888e24f 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -1141,9 +1141,8 @@ of10_phy_ports_print(netdissect_options *ndo, ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* name */ - ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN); ND_PRINT(", name '"); - nd_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN); + (void)nd_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN); ND_PRINT("'"); cp += OFP_MAX_PORT_NAME_LEN; @@ -1759,33 +1758,28 @@ of10_desc_stats_reply_print(netdissect_options *ndo, if (len != OF_DESC_STATS_LEN) goto invalid; /* mfr_desc */ - ND_TCHECK_LEN(cp, DESC_STR_LEN); ND_PRINT("\n\t mfr_desc '"); - nd_print(ndo, cp, cp + DESC_STR_LEN); + (void)nd_print(ndo, cp, cp + DESC_STR_LEN); ND_PRINT("'"); cp += DESC_STR_LEN; /* hw_desc */ - ND_TCHECK_LEN(cp, DESC_STR_LEN); ND_PRINT("\n\t hw_desc '"); - nd_print(ndo, cp, cp + DESC_STR_LEN); + (void)nd_print(ndo, cp, cp + DESC_STR_LEN); ND_PRINT("'"); cp += DESC_STR_LEN; /* sw_desc */ - ND_TCHECK_LEN(cp, DESC_STR_LEN); ND_PRINT("\n\t sw_desc '"); - nd_print(ndo, cp, cp + DESC_STR_LEN); + (void)nd_print(ndo, cp, cp + DESC_STR_LEN); ND_PRINT("'"); cp += DESC_STR_LEN; /* serial_num */ - ND_TCHECK_LEN(cp, SERIAL_NUM_LEN); ND_PRINT("\n\t serial_num '"); - nd_print(ndo, cp, cp + SERIAL_NUM_LEN); + (void)nd_print(ndo, cp, cp + SERIAL_NUM_LEN); ND_PRINT("'"); cp += SERIAL_NUM_LEN; /* dp_desc */ - ND_TCHECK_LEN(cp, DESC_STR_LEN); ND_PRINT("\n\t dp_desc '"); - nd_print(ndo, cp, cp + DESC_STR_LEN); + (void)nd_print(ndo, cp, cp + DESC_STR_LEN); ND_PRINT("'"); return cp + DESC_STR_LEN; @@ -1918,9 +1912,8 @@ of10_table_stats_reply_print(netdissect_options *ndo, ND_TCHECK_3(cp); cp += 3; /* name */ - ND_TCHECK_LEN(cp, OFP_MAX_TABLE_NAME_LEN); ND_PRINT(", name '"); - nd_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN); + (void)nd_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN); ND_PRINT("'"); cp += OFP_MAX_TABLE_NAME_LEN; /* wildcards */ |