]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ospf6.c
CI: Add warning exemptions for Sun C (suncc-5.15) on Solaris 10
[tcpdump] / print-ospf6.c
index 1bdcd68169a04c822fed89f8ddb0c66f414081e5..c6f5f67d9e370573a70f39c51a003882cc70ca0d 100644 (file)
@@ -23,9 +23,7 @@
 
 /* \summary: IPv6 Open Shortest Path First (OSPFv3) printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -381,21 +379,30 @@ ospf6_print_ls_type(netdissect_options *ndo,
                ls_type & LS_TYPE_MASK,
                tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK),
                ls_type &0x8000 ? ", transitive" : "", /* U-bit */
-               GET_IPADDR_STRING((const u_char *)ls_stateid));
+               GET_IPADDR_STRING(ls_stateid));
 }
 
 static int
 ospf6_print_lshdr(netdissect_options *ndo,
                   const struct lsa6_hdr *lshp, const u_char *dataend)
 {
+       u_int ls_length;
+
        if ((const u_char *)(lshp + 1) > dataend)
                goto trunc;
 
+       ls_length = GET_BE_U_2(lshp->ls_length);
+       if (ls_length < sizeof(struct lsa_hdr)) {
+               ND_PRINT("\n\t    Bogus length %u < header (%zu)", ls_length,
+                   sizeof(struct lsa_hdr));
+               goto trunc;
+       }
+
        ND_PRINT("\n\t  Advertising Router %s, seq 0x%08x, age %us, length %zu",
                 GET_IPADDR_STRING(lshp->ls_router),
                 GET_BE_U_4(lshp->ls_seq),
                 GET_BE_U_2(lshp->ls_age),
-                GET_BE_U_2(lshp->ls_length)-sizeof(struct lsa6_hdr));
+                ls_length-sizeof(struct lsa6_hdr));
 
        ospf6_print_ls_type(ndo, GET_BE_U_2(lshp->ls_type),
                            &lshp->ls_stateid);
@@ -552,8 +559,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        if (lsa_length < sizeof (*ap))
                                return (1);
                        lsa_length -= sizeof (*ap);
-                       ND_TCHECK_SIZE(ap);
-                       ND_PRINT("\n\t\t%s", GET_IPADDR_STRING(*ap));
+                       ND_PRINT("\n\t\t%s", GET_IPADDR_STRING(ap));
                        ++ap;
                }
                break;
@@ -653,7 +659,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        prefixes);
 
                tptr = (const uint8_t *)llsap->llsa_prefix;
-               while (prefixes > 0) {
+               while (prefixes != 0) {
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
@@ -685,7 +691,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                ND_PRINT("\n\t      Prefixes %u:", prefixes);
 
                tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
-               while (prefixes > 0) {
+               while (prefixes != 0) {
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
@@ -735,7 +741,7 @@ ospf6_decode_v3(netdissect_options *ndo,
        const struct lsr6 *lsrp;
        const struct lsa6_hdr *lshp;
        const struct lsa6 *lsap;
-       int i;
+       uint32_t i;
 
        switch (GET_U_1(op->ospf6_type)) {
 
@@ -762,8 +768,7 @@ ospf6_decode_v3(netdissect_options *ndo,
                        ND_PRINT("\n\t  Neighbor List:");
                        ap = hellop->hello_neighbor;
                        while ((const u_char *)ap < dataend) {
-                               ND_TCHECK_SIZE(ap);
-                               ND_PRINT("\n\t    %s", GET_IPADDR_STRING(*ap));
+                               ND_PRINT("\n\t    %s", GET_IPADDR_STRING(ap));
                                ++ap;
                        }
                }