diff options
-rw-r--r-- | CONTRIBUTING | 4 | ||||
-rw-r--r-- | netdissect.h | 4 | ||||
-rw-r--r-- | print-ahcp.c | 18 | ||||
-rw-r--r-- | print-aoe.c | 12 | ||||
-rw-r--r-- | print-babel.c | 4 | ||||
-rw-r--r-- | print-bgp.c | 2 | ||||
-rw-r--r-- | print-dtp.c | 2 | ||||
-rw-r--r-- | print-hncp.c | 60 | ||||
-rw-r--r-- | print-icmp6.c | 2 | ||||
-rw-r--r-- | print-ip.c | 2 | ||||
-rw-r--r-- | print-isoclns.c | 3 | ||||
-rw-r--r-- | print-lisp.c | 2 | ||||
-rw-r--r-- | print-loopback.c | 4 | ||||
-rw-r--r-- | print-m3ua.c | 6 | ||||
-rw-r--r-- | print-ntp.c | 4 | ||||
-rw-r--r-- | print-openflow-1.0.c | 36 | ||||
-rw-r--r-- | print-openflow.c | 2 | ||||
-rw-r--r-- | print-ospf.c | 2 | ||||
-rw-r--r-- | print-rpki-rtr.c | 2 | ||||
-rw-r--r-- | print-rsvp.c | 2 | ||||
-rw-r--r-- | print-udld.c | 2 | ||||
-rw-r--r-- | util-print.c | 10 |
22 files changed, 93 insertions, 92 deletions
diff --git a/CONTRIBUTING b/CONTRIBUTING index fae4c739..4e94d645 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -148,8 +148,8 @@ d) The printer may receive incomplete packet in the buffer, truncated at any e) Do invalid packet checks in code: Think that your code can receive in input not only a valid packet but any arbitrary random sequence of octets (packet - built malformed originally by the sender or by a fuzz tester, - - became corrupted in transit). - Print with: ND_PRINT("%s", istr); /* to print " (invalid)" */ + - became corrupted in transit or for some other reason). + Print with: nd_print_invalid(ndo); /* to print " (invalid)" */ f) Use 'struct tok' for indexed strings and print them with tok2str() or bittok2str() (for flags). diff --git a/netdissect.h b/netdissect.h index 0f499a7d..d73f0358 100644 --- a/netdissect.h +++ b/netdissect.h @@ -119,9 +119,6 @@ typedef unsigned char nd_byte; #include "ip.h" /* struct ip for nextproto4_cksum() */ #include "ip6.h" /* struct ip6 for nextproto6_cksum() */ -/* invalid string to print '(invalid)' for malformed or corrupted packets */ -extern const char istr[]; - #ifndef HAVE_STRLCAT extern size_t strlcat (char *, const char *, size_t); #endif @@ -665,6 +662,7 @@ extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const /* Utilities */ extern void nd_print_trunc(netdissect_options *); +extern void nd_print_invalid(netdissect_options *); extern int mask2plen(uint32_t); extern int mask62plen(const u_char *); diff --git a/print-ahcp.c b/print-ahcp.c index 0f6a49f1..33866de0 100644 --- a/print-ahcp.c +++ b/print-ahcp.c @@ -116,7 +116,7 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -134,7 +134,7 @@ ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -158,7 +158,7 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -182,7 +182,7 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -206,7 +206,7 @@ ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -230,7 +230,7 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return 0; trunc: @@ -291,7 +291,7 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -336,7 +336,7 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -403,7 +403,7 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: diff --git a/print-aoe.c b/print-aoe.c index b9d0d718..411ecf1c 100644 --- a/print-aoe.c +++ b/print-aoe.c @@ -194,7 +194,7 @@ aoev1_issue_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -243,7 +243,7 @@ aoev1_query_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -294,7 +294,7 @@ aoev1_mac_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -329,7 +329,7 @@ aoev1_reserve_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -387,7 +387,7 @@ aoev1_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -420,7 +420,7 @@ aoe_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: diff --git a/print-babel.c b/print-babel.c index cb4e90b2..84acf863 100644 --- a/print-babel.c +++ b/print-babel.c @@ -336,7 +336,7 @@ subtlvs_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); } #define ICHECK(i, l) \ @@ -732,6 +732,6 @@ babel_print_v2(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; } diff --git a/print-bgp.c b/print-bgp.c index 70a7645d..974c5e85 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -2581,7 +2581,7 @@ bgp_capabilities_print(netdissect_options *ndo, cap_offset=2; while (tcap_len != 0) { if (tcap_len < 4) { - ND_PRINT("\n\t\t(invalid)"); + nd_print_invalid(ndo); break; } ND_PRINT("\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s", diff --git a/print-dtp.c b/print-dtp.c index b84da3fb..004f7d31 100644 --- a/print-dtp.c +++ b/print-dtp.c @@ -114,7 +114,7 @@ dtp_print(netdissect_options *ndo, const u_char *pptr, u_int length) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; trunc: nd_print_trunc(ndo); diff --git a/print-hncp.c b/print-hncp.c index caab53ce..c195068e 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -345,7 +345,7 @@ dhcpv6_print(netdissect_options *ndo, case DH6OPT_DNS_SERVERS: case DH6OPT_SNTP_SERVERS: { if (optlen % 16 != 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return -1; } for (t = 0; t < optlen; t += 16) @@ -479,14 +479,14 @@ hncp_print_rec(netdissect_options *ndo, case DNCP_REQUEST_NETWORK_STATE: { if (bodylen != 0) - ND_PRINT("%s", istr); + nd_print_invalid(ndo); } break; case DNCP_REQUEST_NODE_STATE: { const char *node_identifier; if (bodylen != 4) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } node_identifier = format_nid(value); @@ -498,7 +498,7 @@ hncp_print_rec(netdissect_options *ndo, const char *node_identifier; uint32_t endpoint_identifier; if (bodylen != 8) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } node_identifier = format_nid(value); @@ -513,7 +513,7 @@ hncp_print_rec(netdissect_options *ndo, case DNCP_NETWORK_STATE: { uint64_t hash; if (bodylen != 8) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } hash = EXTRACT_BE_U_8(value); @@ -526,7 +526,7 @@ hncp_print_rec(netdissect_options *ndo, uint32_t sequence_number; uint64_t hash; if (bodylen < 20) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } node_identifier = format_nid(value); @@ -547,7 +547,7 @@ hncp_print_rec(netdissect_options *ndo, const char *peer_node_identifier; uint32_t peer_endpoint_identifier, endpoint_identifier; if (bodylen != 12) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } peer_node_identifier = format_nid(value); @@ -565,7 +565,7 @@ hncp_print_rec(netdissect_options *ndo, uint32_t endpoint_identifier; const char *interval; if (bodylen < 8) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } endpoint_identifier = EXTRACT_BE_U_4(value); @@ -579,7 +579,7 @@ hncp_print_rec(netdissect_options *ndo, case DNCP_TRUST_VERDICT: { if (bodylen <= 36) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT(" Verdict: %u Fingerprint: %s Common Name: ", @@ -593,7 +593,7 @@ hncp_print_rec(netdissect_options *ndo, uint16_t capabilities; uint8_t M, P, H, L; if (bodylen < 5) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } capabilities = EXTRACT_BE_U_2(value + 2); @@ -617,7 +617,7 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_DELEGATED_PREFIX: { int l; if (bodylen < 9 || bodylen < 9 + (EXTRACT_U_1(value + 8) + 7) / 8) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT(" VLSO: %s PLSO: %s Prefix: ", @@ -639,7 +639,7 @@ hncp_print_rec(netdissect_options *ndo, * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } l += 8 + (-l & 3); @@ -653,14 +653,14 @@ hncp_print_rec(netdissect_options *ndo, uint8_t policy; int l; if (bodylen < 1) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } policy = EXTRACT_U_1(value); ND_PRINT(" type: "); if (policy == 0) { if (bodylen != 1) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT("Internet connectivity"); @@ -681,7 +681,7 @@ hncp_print_rec(netdissect_options *ndo, * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } } else if (policy == 129) { @@ -692,7 +692,7 @@ hncp_print_rec(netdissect_options *ndo, (void)nd_printzp(ndo, value + 1, bodylen - 1, NULL); } else if (policy == 131) { if (bodylen != 1) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT("Restrictive assignment"); @@ -704,7 +704,7 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_DHCPV4_DATA: { if (bodylen == 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } if (dhcpv4_print(ndo, value, bodylen, indent+1) != 0) @@ -714,11 +714,11 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_DHCPV6_DATA: { if (bodylen == 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } if (dhcpv6_print(ndo, value, bodylen, indent+1) != 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } } @@ -728,7 +728,7 @@ hncp_print_rec(netdissect_options *ndo, uint8_t prty; int l; if (bodylen < 6 || bodylen < 6 + (EXTRACT_U_1(value + 5) + 7) / 8) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } prty = EXTRACT_U_1(value + 4) & 0xf; @@ -738,7 +738,7 @@ hncp_print_rec(netdissect_options *ndo, ); ND_PRINT(" Prefix: "); if ((l = print_prefix(ndo, value + 5, bodylen - 5)) < 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } l += 5; @@ -753,7 +753,7 @@ hncp_print_rec(netdissect_options *ndo, uint32_t endpoint_identifier; const char *ip_address; if (bodylen < 20) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } endpoint_identifier = EXTRACT_BE_U_4(value); @@ -771,7 +771,7 @@ hncp_print_rec(netdissect_options *ndo, const char *ip_address; int len; if (bodylen < 17) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ip_address = format_ip6addr(ndo, value); @@ -783,7 +783,7 @@ hncp_print_rec(netdissect_options *ndo, ); len = print_dns_label(ndo, value+17, bodylen-17, 1); if (len < 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } len += 17; @@ -795,7 +795,7 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_DOMAIN_NAME: { if (bodylen == 0) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT(" Domain: "); @@ -806,12 +806,12 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_NODE_NAME: { u_int l; if (bodylen < 17) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } l = EXTRACT_U_1(value + 16); if (bodylen < 17 + l) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT(" IP-Address: %s Name: ", @@ -822,7 +822,7 @@ hncp_print_rec(netdissect_options *ndo, (void)nd_printzp(ndo, value + 17, l, NULL); ND_PRINT("\""); } else { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); } l += 17; l += -l & 3; @@ -833,7 +833,7 @@ hncp_print_rec(netdissect_options *ndo, case HNCP_MANAGED_PSK: { if (bodylen < 32) { - ND_PRINT("%s", istr); + nd_print_invalid(ndo); break; } ND_PRINT(" PSK: %s", format_256(value)); @@ -861,6 +861,6 @@ hncp_print_rec(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; } diff --git a/print-icmp6.c b/print-icmp6.c index 52f58a0e..37f513e2 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1041,7 +1041,7 @@ icmp6_print(netdissect_options *ndo, ep = ndo->ndo_snapend; if (length == 0) { ND_PRINT("ICMP6, length 0"); - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; } @@ -558,7 +558,7 @@ ip_print(netdissect_options *ndo, ND_PRINT("IP6, wrong link-layer encapsulation"); else ND_PRINT("IP%u", IP_V(ipds->ip)); - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; } if (!ndo->ndo_eflag) diff --git a/print-isoclns.c b/print-isoclns.c index b9935ebd..5a0b4288 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -2697,7 +2697,8 @@ isis_print(netdissect_options *ndo, lan_alen = EXTRACT_U_1(tptr); /* LAN address length */ tptr++; if (lan_alen == 0) { - ND_PRINT("\n\t LAN address length 0 bytes (invalid)"); + ND_PRINT("\n\t LAN address length 0 bytes"); + nd_print_invalid(ndo); break; } tmp --; diff --git a/print-lisp.c b/print-lisp.c index 0d9f67d2..74290639 100644 --- a/print-lisp.c +++ b/print-lisp.c @@ -389,7 +389,7 @@ trunc: nd_print_trunc(ndo); return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; } diff --git a/print-loopback.c b/print-loopback.c index e47e404d..ea7d7280 100644 --- a/print-loopback.c +++ b/print-loopback.c @@ -96,7 +96,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: @@ -126,7 +126,7 @@ loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return; trunc: diff --git a/print-m3ua.c b/print-m3ua.c index 180b4213..7e2b0c8c 100644 --- a/print-m3ua.c +++ b/print-m3ua.c @@ -229,7 +229,7 @@ tag_value_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(buf, size); return; trunc: @@ -277,7 +277,7 @@ m3ua_tags_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(buf, size); return; trunc: @@ -333,7 +333,7 @@ m3ua_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(buf, size); return; trunc: diff --git a/print-ntp.c b/print-ntp.c index 5c9b6dcf..9cfda05f 100644 --- a/print-ntp.c +++ b/print-ntp.c @@ -371,7 +371,7 @@ ntp_time_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(bp, length); return; @@ -431,7 +431,7 @@ ntp_control_print(netdissect_options *ndo, return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cd, length); return; diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 0b2e7bbc..d019f492 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -947,7 +947,7 @@ of10_bsn_message_print(netdissect_options *ndo, return cp; invalid: /* skip the undersized data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len); return cp0 + len; trunc: @@ -1021,7 +1021,7 @@ of10_bsn_actions_print(netdissect_options *ndo, return cp; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len); return cp0 + len; trunc: @@ -1050,7 +1050,7 @@ of10_vendor_action_print(netdissect_options *ndo, return decoder(ndo, cp, ep, len - 4); invalid: /* skip the undersized data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); return cp + len; trunc: @@ -1079,7 +1079,7 @@ of10_vendor_message_print(netdissect_options *ndo, return decoder(ndo, cp, ep, len - 4); invalid: /* skip the undersized data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); return cp + len; trunc: @@ -1105,7 +1105,7 @@ of10_vendor_data_print(netdissect_options *ndo, return of10_data_print(ndo, cp, ep, len - 4); invalid: /* skip the undersized data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); return cp + len; trunc: @@ -1208,7 +1208,7 @@ next_port: return cp; invalid: /* skip the undersized trailing data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1284,7 +1284,7 @@ next_property: return cp; invalid: /* skip the rest of queue properties */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1332,7 +1332,7 @@ next_queue: return cp; invalid: /* skip the rest of queues */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1603,7 +1603,7 @@ next_action: return cp; invalid: /* skip the rest of actions */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1821,7 +1821,7 @@ of10_stats_request_print(netdissect_options *ndo, return cp; invalid: /* skip the message body */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1868,7 +1868,7 @@ of10_desc_stats_reply_print(netdissect_options *ndo, return cp + DESC_STR_LEN; invalid: /* skip the message body */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); return cp + len; trunc: @@ -1949,7 +1949,7 @@ of10_flow_stats_reply_print(netdissect_options *ndo, return cp; invalid: /* skip the rest of flow statistics entries */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -1982,7 +1982,7 @@ of10_aggregate_stats_reply_print(netdissect_options *ndo, return cp + 4; invalid: /* skip the message body */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); return cp + len; trunc: @@ -2042,7 +2042,7 @@ of10_table_stats_reply_print(netdissect_options *ndo, return cp; invalid: /* skip the undersized trailing data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -2127,7 +2127,7 @@ next_port: return cp; invalid: /* skip the undersized trailing data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -2175,7 +2175,7 @@ of10_queue_stats_reply_print(netdissect_options *ndo, return cp; invalid: /* skip the undersized trailing data */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -2254,7 +2254,7 @@ of10_packet_out_print(netdissect_options *ndo, return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len); invalid: /* skip the rest of the message body */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp0, len0); return cp0 + len0; trunc: @@ -2557,7 +2557,7 @@ of10_header_body_print(netdissect_options *ndo, goto next_message; invalid: /* skip the message body */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); next_message: ND_TCHECK_LEN(cp0, len0 - OF_HEADER_LEN); return cp0 + len0 - OF_HEADER_LEN; diff --git a/print-openflow.c b/print-openflow.c index f3c1a832..8a912063 100644 --- a/print-openflow.c +++ b/print-openflow.c @@ -120,7 +120,7 @@ of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep } invalid: /* fail current packet */ - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(cp, ep - cp); return ep; trunc: diff --git a/print-ospf.c b/print-ospf.c index eebf17b2..2a502a6c 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -503,7 +503,7 @@ ospf_te_lsa_print(netdissect_options *ndo, trunc: return -1; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return -1; } diff --git a/print-rpki-rtr.c b/print-rpki-rtr.c index 38f1e051..86b36a9a 100644 --- a/print-rpki-rtr.c +++ b/print-rpki-rtr.c @@ -376,7 +376,7 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, const u_int len return pdu_len; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); ND_TCHECK_LEN(tptr, len); return len; trunc: diff --git a/print-rsvp.c b/print-rsvp.c index 2875a175..2ebbc631 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -1862,7 +1862,7 @@ rsvp_obj_print(netdissect_options *ndo, } return 0; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return -1; trunc: nd_print_trunc(ndo); diff --git a/print-udld.c b/print-udld.c index 224d4825..e17e7128 100644 --- a/print-udld.c +++ b/print-udld.c @@ -184,7 +184,7 @@ udld_print(netdissect_options *ndo, const u_char *pptr, u_int length) return; invalid: - ND_PRINT("%s", istr); + nd_print_invalid(ndo); return; trunc: nd_print_trunc(ndo); diff --git a/util-print.c b/util-print.c index 45da51f7..5a8c8fe5 100644 --- a/util-print.c +++ b/util-print.c @@ -57,12 +57,8 @@ #include "ascii_strcasecmp.h" #include "timeval-operations.h" -/* invalid string to print '(invalid)' for malformed or corrupted packets */ -const char istr[] = " (invalid)"; - #define TOKBUFSIZE 128 - enum date_flag { WITHOUT_DATE = 0, WITH_DATE = 1 }; enum time_flag { UTC_TIME = 0, LOCAL_TIME = 1 }; @@ -444,6 +440,12 @@ void nd_print_trunc(netdissect_options *ndo) ND_PRINT(" [|%s]", ndo->ndo_protocol); } +/* Print the invalid string */ +void nd_print_invalid(netdissect_options *ndo) +{ + ND_PRINT(" (invalid)"); +} + /* * this is a generic routine for printing unknown data; * we pass on the linefeed plus indentation string to |