X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/7885cfa165458a05ef818c34ee03affc79f03725..refs/heads/coverity_scan:/print-vqp.c diff --git a/print-vqp.c b/print-vqp.c index e120de16..dca3c1e6 100644 --- a/print-vqp.c +++ b/print-vqp.c @@ -17,17 +17,16 @@ /* \summary: Cisco VLAN Query Protocol (VQP) printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" -#define VQP_VERSION 1 +#define VQP_VERSION 1 /* * VQP common header @@ -114,7 +113,7 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) vqp_common_header = (const struct vqp_common_header_t *)pptr; ND_TCHECK_SIZE(vqp_common_header); if (sizeof(struct vqp_common_header_t) > tlen) - goto trunc; + goto invalid; version = GET_U_1(vqp_common_header->version); /* @@ -131,7 +130,7 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) ND_PRINT("VQPv%u %s Message, error-code %s (%u), length %u", version, tok2str(vqp_msg_type_values, "unknown (%u)",GET_U_1(vqp_common_header->msg_type)), - tok2str(vqp_error_code_values, "unknown (%u)",GET_U_1(vqp_common_header->error_code)), + tok2str(vqp_error_code_values, "unknown", GET_U_1(vqp_common_header->error_code)), GET_U_1(vqp_common_header->error_code), len); return; @@ -142,7 +141,7 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) ND_PRINT("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u", version, tok2str(vqp_msg_type_values, "unknown (%u)",GET_U_1(vqp_common_header->msg_type)), - tok2str(vqp_error_code_values, "unknown (%u)",GET_U_1(vqp_common_header->error_code)), + tok2str(vqp_error_code_values, "unknown", GET_U_1(vqp_common_header->error_code)), GET_U_1(vqp_common_header->error_code), GET_BE_U_4(vqp_common_header->sequence), nitems, @@ -157,7 +156,7 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) vqp_obj_tlv = (const struct vqp_obj_tlv_t *)tptr; ND_TCHECK_SIZE(vqp_obj_tlv); if (sizeof(struct vqp_obj_tlv_t) > tlen) - goto trunc; + goto invalid; vqp_obj_type = GET_BE_U_4(vqp_obj_tlv->obj_type); vqp_obj_len = GET_BE_U_2(vqp_obj_tlv->obj_length); tptr+=sizeof(struct vqp_obj_tlv_t); @@ -175,12 +174,12 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) /* did we capture enough for fully decoding the object ? */ ND_TCHECK_LEN(tptr, vqp_obj_len); if (vqp_obj_len > tlen) - goto trunc; + goto invalid; switch(vqp_obj_type) { case VQP_OBJ_IP_ADDRESS: if (vqp_obj_len != 4) - goto trunc; + goto invalid; ND_PRINT("%s (0x%08x)", GET_IPADDR_STRING(tptr), GET_BE_U_4(tptr)); break; @@ -189,14 +188,14 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) case VQP_OBJ_VLAN_NAME: case VQP_OBJ_VTP_DOMAIN: case VQP_OBJ_ETHERNET_PKT: - (void)nd_printzp(ndo, tptr, vqp_obj_len, NULL); + nd_printjnp(ndo, tptr, vqp_obj_len); break; /* those objects have similar semantics - fall through */ case VQP_OBJ_MAC_ADDRESS: case VQP_OBJ_MAC_NULL: - if (vqp_obj_len != MAC_ADDR_LEN) - goto trunc; - ND_PRINT("%s", GET_ETHERADDR_STRING(tptr)); + if (vqp_obj_len != MAC48_LEN) + goto invalid; + ND_PRINT("%s", GET_MAC48_STRING(tptr)); break; default: if (ndo->ndo_vflag <= 1) @@ -208,6 +207,6 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len) nitems--; } return; -trunc: - nd_print_trunc(ndo); +invalid: + nd_print_invalid(ndo); }