]> The Tcpdump Group git mirrors - tcpdump/blobdiff - smbutil.c
Use more the EXTRACT_8BITS() macro to fetch a one-byte value (11/n)
[tcpdump] / smbutil.c
index e6114fa37330a0be518dc6ffc511cfc6de478636..71ad60d9b491bee81f9b995f93c484eead8468e3 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -185,7 +185,7 @@ name_ptr(netdissect_options *ndo,
        ND_TCHECK2(*p, 2);
        if ((p + 1) >= maxbuf)
            return(NULL);       /* name goes past the end of the buffer */
-       l = EXTRACT_16BITS(p) & 0x3FFF;
+       l = EXTRACT_BE_16BITS(p) & 0x3FFF;
        if (l == 0) {
            /* We have a pointer that points to itself. */
            return(NULL);
@@ -237,6 +237,7 @@ name_len(netdissect_options *ndo,
            return(-1); /* name goes past the end of the buffer */
        ND_TCHECK2(*s, 1);
        s += (*s) + 1;
+       ND_TCHECK2(*s, 1);
     }
     return(PTR_DIFF(s, s0) + 1);
 
@@ -271,8 +272,7 @@ name_type_str(int name_type)
 }
 
 void
-print_data(netdissect_options *ndo,
-           const unsigned char *buf, int len)
+smb_print_data(netdissect_options *ndo, const unsigned char *buf, int len)
 {
     int i = 0;
 
@@ -504,7 +504,7 @@ smb_fdata1(netdissect_options *ndo,
          {
            unsigned int x;
            ND_TCHECK2(buf[0], 2);
-           x = reverse ? EXTRACT_16BITS(buf) :
+           x = reverse ? EXTRACT_BE_16BITS(buf) :
                          EXTRACT_LE_16BITS(buf);
            ND_PRINT((ndo, "%d (0x%x)", x, x));
            buf += 2;
@@ -515,7 +515,7 @@ smb_fdata1(netdissect_options *ndo,
          {
            unsigned int x;
            ND_TCHECK2(buf[0], 4);
-           x = reverse ? EXTRACT_32BITS(buf) :
+           x = reverse ? EXTRACT_BE_32BITS(buf) :
                          EXTRACT_LE_32BITS(buf);
            ND_PRINT((ndo, "%d (0x%x)", x, x));
            buf += 4;
@@ -526,7 +526,7 @@ smb_fdata1(netdissect_options *ndo,
          {
            uint64_t x;
            ND_TCHECK2(buf[0], 8);
-           x = reverse ? EXTRACT_64BITS(buf) :
+           x = reverse ? EXTRACT_BE_64BITS(buf) :
                          EXTRACT_LE_64BITS(buf);
            ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
            buf += 8;
@@ -539,9 +539,9 @@ smb_fdata1(netdissect_options *ndo,
            uint32_t x1, x2;
            uint64_t x;
            ND_TCHECK2(buf[0], 8);
-           x1 = reverse ? EXTRACT_32BITS(buf) :
+           x1 = reverse ? EXTRACT_BE_32BITS(buf) :
                           EXTRACT_LE_32BITS(buf);
-           x2 = reverse ? EXTRACT_32BITS(buf + 4) :
+           x2 = reverse ? EXTRACT_BE_32BITS(buf + 4) :
                           EXTRACT_LE_32BITS(buf + 4);
            x = (((uint64_t)x1) << 32) | x2;
            ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
@@ -563,7 +563,7 @@ smb_fdata1(netdissect_options *ndo,
          {
            unsigned int x;
            ND_TCHECK2(buf[0], 2);
-           x = reverse ? EXTRACT_16BITS(buf) :
+           x = reverse ? EXTRACT_BE_16BITS(buf) :
                          EXTRACT_LE_16BITS(buf);
            ND_PRINT((ndo, "0x%X", x));
            buf += 2;
@@ -574,7 +574,7 @@ smb_fdata1(netdissect_options *ndo,
          {
            unsigned int x;
            ND_TCHECK2(buf[0], 4);
-           x = reverse ? EXTRACT_32BITS(buf) :
+           x = reverse ? EXTRACT_BE_32BITS(buf) :
                          EXTRACT_LE_32BITS(buf);
            ND_PRINT((ndo, "0x%X", x));
            buf += 4;
@@ -595,7 +595,7 @@ smb_fdata1(netdissect_options *ndo,
 
            case 'd':
                ND_TCHECK2(buf[0], 2);
-               stringlen = reverse ? EXTRACT_16BITS(buf) :
+               stringlen = reverse ? EXTRACT_BE_16BITS(buf) :
                                      EXTRACT_LE_16BITS(buf);
                ND_PRINT((ndo, "%u", stringlen));
                buf += 2;
@@ -603,7 +603,7 @@ smb_fdata1(netdissect_options *ndo,
 
            case 'D':
                ND_TCHECK2(buf[0], 4);
-               stringlen = reverse ? EXTRACT_32BITS(buf) :
+               stringlen = reverse ? EXTRACT_BE_32BITS(buf) :
                                      EXTRACT_LE_32BITS(buf);
                ND_PRINT((ndo, "%u", stringlen));
                buf += 4;
@@ -860,7 +860,7 @@ smb_fdata(netdissect_options *ndo,
     if (!depth && buf < maxbuf) {
        size_t len = PTR_DIFF(maxbuf, buf);
        ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len));
-       print_data(ndo, buf, len);
+       smb_print_data(ndo, buf, len);
        return(buf + len);
     }
     return(buf);