]> The Tcpdump Group git mirrors - tcpdump/commitdiff
RIP: Print an error message for an invalid version
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 15 Aug 2022 08:43:08 +0000 (10:43 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 15 Aug 2022 08:54:54 +0000 (10:54 +0200)
Moreover:
RIP: Print the protocol name even in truncation case or invalid length.

print-rip.c

index 265222a19fe52d9b8fe3a5da16f5ec5a844e168e..3567255107c83ba08a07559ce1fba030b30a752b 100644 (file)
@@ -300,14 +300,18 @@ rip_print(netdissect_options *ndo,
        unsigned entry_size;
 
        ndo->ndo_protocol = "rip";
+       ND_PRINT("%s", (ndo->ndo_vflag >= 1) ? "\n\t" : "");
+       nd_print_protocol_caps(ndo);
        ND_ICHECKMSG_ZU("packet length", len, <, sizeof(*rp));
 
        rp = (const struct rip *)p;
 
        vers = GET_U_1(rp->rip_vers);
-       ND_PRINT("%sRIPv%u",
-                (ndo->ndo_vflag >= 1) ? "\n\t" : "",
-                vers);
+       ND_PRINT("v%u", vers);
+       if (vers != 1 && vers != 2) {
+               ND_PRINT(" [version != 1 && version != 2]");
+               goto invalid;
+       }
 
        /* dump version and lets see if we know the commands name*/
        cmd = GET_U_1(rp->rip_cmd);