X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/cc3be3c89d7fd8582cebbe236273783527532e99..9169e4e1949c3fa879f0a2f98cfbd8c444743c27:/print-ospf.c diff --git a/print-ospf.c b/print-ospf.c index f5f37a3b..a385d7a1 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -582,7 +582,7 @@ static const struct tok ospf_topology_values[] = { /* * Print all the per-topology metrics. */ -static int +static void ospf_print_tos_metrics(netdissect_options *ndo, const union un_tos *tos) { @@ -597,7 +597,6 @@ ospf_print_tos_metrics(netdissect_options *ndo, * All but the first metric contain a valid topology id. */ while (toscount != 0) { - ND_TCHECK_SIZE(tos); tos_type = GET_U_1(tos->metrics.tos_type); ND_PRINT("\n\t\ttopology %s (%u), metric %u", tok2str(ospf_topology_values, "Unknown", @@ -608,9 +607,6 @@ ospf_print_tos_metrics(netdissect_options *ndo, tos++; toscount--; } - return 0; -trunc: - return 1; } /* @@ -688,8 +684,7 @@ ospf_print_lsa(netdissect_options *ndo, return (ls_end); } - if (ospf_print_tos_metrics(ndo, &rlp->un_tos)) - goto trunc; + ospf_print_tos_metrics(ndo, &rlp->un_tos); rlp = (const struct rlalink *)((const u_char *)(rlp + 1) + (GET_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos))); @@ -889,7 +884,7 @@ trunc: return (NULL); } -static int +static void ospf_decode_lls(netdissect_options *ndo, const struct ospfhdr *op, u_int length) { @@ -903,16 +898,16 @@ ospf_decode_lls(netdissect_options *ndo, case OSPF_TYPE_HELLO: if (!(GET_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L)) - return (0); + return; break; case OSPF_TYPE_DD: if (!(GET_U_1(op->ospf_db.db_options) & OSPF_OPTION_L)) - return (0); + return; break; default: - return (0); + return; } /* dig deeper if LLS data is available; see RFC4813 */ @@ -921,12 +916,12 @@ ospf_decode_lls(netdissect_options *ndo, dataend = (const u_char *)op + length; if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) { - dptr = dptr + op->ospf_authdata[3]; - length2 += op->ospf_authdata[3]; + dptr = dptr + GET_U_1(op->ospf_authdata + 3); + length2 += GET_U_1(op->ospf_authdata + 3); } if (length2 >= length) { ND_PRINT("\n\t[LLS truncated]"); - return (1); + return; } ND_PRINT("\n\t LLS: checksum: 0x%04x", (u_int) GET_BE_U_2(dptr)); @@ -968,8 +963,6 @@ ospf_decode_lls(netdissect_options *ndo, dptr += lls_len; } - - return (0); } static int @@ -1154,8 +1147,8 @@ ospf_print(netdissect_options *ndo, case OSPF_AUTH_MD5: ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x", - *((op->ospf_authdata) + 2), - *((op->ospf_authdata) + 3), + GET_U_1(op->ospf_authdata + 2), + GET_U_1(op->ospf_authdata + 3), GET_BE_U_4((op->ospf_authdata) + 4)); break; @@ -1170,10 +1163,8 @@ ospf_print(netdissect_options *ndo, /* ospf version 2 */ if (ospf_decode_v2(ndo, op, dataend)) goto trunc; - if (length > GET_BE_U_2(op->ospf_len)) { - if (ospf_decode_lls(ndo, op, length)) - goto trunc; - } + if (length > GET_BE_U_2(op->ospf_len)) + ospf_decode_lls(ndo, op, length); break; default: @@ -1183,5 +1174,5 @@ ospf_print(netdissect_options *ndo, return; trunc: - nd_print_trunc(ndo); + nd_trunc_longjmp(ndo); }