]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ZEP: Fix invalid Preamble Code processing
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 6 Oct 2020 13:26:37 +0000 (15:26 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 6 Oct 2020 13:35:46 +0000 (15:35 +0200)
It's an invalid case, not a truncated one.

Moreover:
Update a comment.

print-zep.c

index 017049d49da93764d463e7722f69f3fb0a2a13ce..c50db7a98761d96cba3fd6bc130a78a7ffe1bf70 100644 (file)
@@ -43,7 +43,6 @@
  ***********************************************************************
  *
  * ZEP v1 Header will have the following format:
- *
  * |Preamble|Version|Channel ID|Device ID|CRC/LQI Mode|LQI Val|Reserved|Length|
  * |2 bytes |1 byte |  1 byte  | 2 bytes |   1 byte   |1 byte |7 bytes |1 byte|
  *
@@ -110,8 +109,15 @@ zep_print(netdissect_options *ndo,
 
        ND_TCHECK_LEN(bp, 8);
 
-       if (GET_U_1(bp) != 'E' || GET_U_1(bp + 1) != 'X')
-               goto trunc;
+       /* Preamble Code (must be "EX") */
+       if (GET_U_1(bp) != 'E' || GET_U_1(bp + 1) != 'X') {
+               ND_PRINT(" [Preamble Code: ");
+               fn_print_char(ndo, GET_U_1(bp));
+               fn_print_char(ndo, GET_U_1(bp + 1));
+               ND_PRINT("]");
+               nd_print_invalid(ndo);
+               return;
+       }
 
        version = GET_U_1(bp + 2);
        ND_PRINT("v%d ", version);