]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-telnet.c
Use more the EXTRACT_U_1() macro (40/n)
[tcpdump] / print-telnet.c
index f8df48671f873871feb9eb12e80fc91fa9102933..e3782177a9f4c0534bb3759030479cf37ec51e74 100644 (file)
@@ -56,6 +56,7 @@
 #include <stdio.h>
 
 #include "netdissect.h"
+#include "extract.h"
 
 static const char tstr[] = " [|telnet]";
 
@@ -437,10 +438,12 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
                /* IAC SB .... IAC SE */
                p = sp;
                while (length > (u_int)(p + 1 - sp)) {
+                       ND_TCHECK_2(p);
                        if (p[0] == IAC && p[1] == SE)
                                break;
                        p++;
                }
+               ND_TCHECK(*p);
                if (*p != IAC)
                        goto pktend;
 
@@ -513,7 +516,7 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
        osp = sp;
 
        ND_TCHECK(*sp);
-       while (length > 0 && *sp == IAC) {
+       while (length > 0 && EXTRACT_U_1(sp) == IAC) {
                /*
                 * Parse the Telnet command without printing it,
                 * to determine its length.