]> The Tcpdump Group git mirrors - tcpdump/blobdiff - smbutil.c
Fixed some warnings, added print-zep.c to CMakeLists
[tcpdump] / smbutil.c
index ea69d2b8676e74da68f680511ee77c01694224fc..0c1bb23a3be1decabea725e688df2c9f19d29ef1 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -7,10 +7,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -235,11 +235,11 @@ name_len(netdissect_options *ndo,
     c = EXTRACT_U_1(s);
     if ((c & 0xC0) == 0xC0)
        return(2);
-    while (*s) {
+    while (EXTRACT_U_1(s)) {
        if (s >= maxbuf)
            return(-1); /* name goes past the end of the buffer */
        ND_TCHECK_1(s);
-       s += (*s) + 1;
+       s += EXTRACT_U_1(s) + 1;
        ND_TCHECK_1(s);
     }
     return(PTR_DIFF(s, s0) + 1);
@@ -254,7 +254,7 @@ print_asc(netdissect_options *ndo,
 {
     u_int i;
     for (i = 0; i < len; i++)
-        safeputchar(ndo, EXTRACT_U_1(buf + i));
+        fn_print_char(ndo, EXTRACT_U_1(buf + i));
 }
 
 static const char *
@@ -275,7 +275,7 @@ name_type_str(int name_type)
 }
 
 void
-smb_print_data(netdissect_options *ndo, const u_char *buf, u_int len)
+smb_data_print(netdissect_options *ndo, const u_char *buf, u_int len)
 {
     u_int i = 0;
 
@@ -318,8 +318,7 @@ smb_print_data(netdissect_options *ndo, const u_char *buf, u_int len)
     return;
 
 trunc:
-    ND_PRINT("\n");
-    ND_PRINT("WARNING: Short packet. Try increasing the snap length\n");
+    nd_print_trunc(ndo);
 }
 
 
@@ -468,7 +467,7 @@ smb_fdata1(netdissect_options *ndo,
            l = PTR_DIFF(p, fmt);
 
            if (l > sizeof(bitfmt) - 1)
-                   l = sizeof(bitfmt)-1;
+               l = sizeof(bitfmt)-1;
 
            strncpy(bitfmt, fmt, l);
            bitfmt[l] = '\0';
@@ -815,8 +814,7 @@ smb_fdata1(netdissect_options *ndo,
     return(buf);
 
 trunc:
-    ND_PRINT("\n");
-    ND_PRINT("WARNING: Short packet. Try increasing the snap length\n");
+    nd_print_trunc(ndo);
     return(NULL);
 }
 
@@ -889,7 +887,7 @@ smb_fdata(netdissect_options *ndo,
     if (!depth && buf < maxbuf) {
        size_t len = PTR_DIFF(maxbuf, buf);
        ND_PRINT("Data: (%lu bytes)\n", (unsigned long)len);
-       smb_print_data(ndo, buf, len);
+       smb_data_print(ndo, buf, len);
        return(buf + len);
     }
     return(buf);
@@ -1012,7 +1010,7 @@ static const struct {
 /*
  * return a SMB error string from a SMB buffer
  */
-char *
+const char *
 smb_errstr(int class, int num)
 {
     static char ret[128];
@@ -1026,17 +1024,17 @@ smb_errstr(int class, int num)
                const err_code_struct *err = err_classes[i].err_msgs;
                for (j = 0; err[j].name; j++)
                    if (num == err[j].code) {
-                       snprintf(ret, sizeof(ret), "%s - %s (%s)",
+                       nd_snprintf(ret, sizeof(ret), "%s - %s (%s)",
                            err_classes[i].class, err[j].name, err[j].message);
                        return ret;
                    }
            }
 
-           snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
+           nd_snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
            return ret;
        }
 
-    snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
+    nd_snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
     return(ret);
 }
 
@@ -1917,6 +1915,6 @@ nt_errstr(uint32_t err)
            return nt_errors[i].name;
     }
 
-    snprintf(ret, sizeof(ret), "0x%08x", err);
+    nd_snprintf(ret, sizeof(ret), "0x%08x", err);
     return ret;
 }