]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add nd_{v}snprintf() routines/wrappers.
authorGuy Harris <[email protected]>
Mon, 29 Jan 2018 23:48:55 +0000 (15:48 -0800)
committerGuy Harris <[email protected]>
Mon, 29 Jan 2018 23:48:55 +0000 (15:48 -0800)
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).

39 files changed:
CMakeLists.txt
Makefile.in
addrtoname.c
addrtostr.c
interface.h
machdep.c
missing/getservent.c
missing/snprintf.c
missing/win_ether_ntohost.c
missing/win_snprintf.c [deleted file]
netdissect-stdinc.h
netdissect.c
netdissect.h
parsenfsfh.c
print-ascii.c
print-atalk.c
print-babel.c
print-bgp.c
print-cnfp.c
print-decnet.c
print-fr.c
print-hncp.c
print-icmp.c
print-icmp6.c
print-ipx.c
print-isakmp.c
print-isoclns.c
print-lldp.c
print-nfs.c
print-openflow-1.0.c
print-rx.c
print-snmp.c
print-stp.c
print-sunrpc.c
print-telnet.c
print-zephyr.c
smbutil.c
tcpdump.c
util-print.c

index 7e2b9db5b55e8c5ee3e40bddbd71420bfd2f89fc..3482ea8195408d5a0aba05ce29d0134e9e03ee0b 100644 (file)
@@ -204,14 +204,33 @@ cmake_pop_check_state()
 
 check_function_exists(getopt_long HAVE_GETOPT_LONG)
 #
-# With MSVC 2015, stdio.h defines snprintf() and vsnprintf() as inline
-# functions, so you need to include stdio.h when testing for them -
-# check_function_exists() won't do it, you need check_symbol_exists().
-#
-check_symbol_exists(vsnprintf stdio.h HAVE_VSNPRINTF)
-check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
-check_function_exists(fork HAVE_FORK)
-check_function_exists(vfork HAVE_VFORK)
+# For Windows, either
+#
+#   1) we're using VS 2015, in which case we have both snprintf()
+#      and vsnprintf(), and they behave in a C99-compliant fashion,
+#      so we use them
+#
+# or
+#
+#   2) we're not, and we don't have snprintf(), and we either don't
+#      have vsnprintf() or we have one that *doesn't* behave in a
+#      C99-compliant fashion, but we *do* have _snprintf_s() and
+#      _vsnprintf_s(), so we wrap them with #defines
+#
+# and we test for both of them at compile time, so we don't need to
+# check for snprintf() or vsnprintf() here.
+#
+# XXX - do we need to care about UN*Xes that don't have snprintf()
+# or vsnprintf() any more?
+#
+# We also don't need to waste time checking for fork() or vfork().
+#
+if(NOT WIN32)
+  check_function_exists(vsnprintf HAVE_VSNPRINTF)
+  check_function_exists(snprintf HAVE_SNPRINTF)
+  check_function_exists(fork HAVE_FORK)
+  check_function_exists(vfork HAVE_VFORK)
+endif(NOT WIN32)
 check_function_exists(strftime HAVE_STRFTIME)
 check_function_exists(setlinebuf HAVE_SETLINEBUF)
 
@@ -920,13 +939,11 @@ foreach(FUNC strlcat strlcpy strdup strsep getservent getopt_long)
         set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c)
     endif()
 endforeach()
-if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
-    if(WIN32)
-        set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/win_snprintf.c)
-    else(WIN32)
+if(NOT WIN32)
+    if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
         set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/snprintf.c)
-    endif(WIN32)
-endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
+    endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
+endif(NOT WIN32)
 
 add_library(netdissect STATIC
     ${NETDISSECT_SOURCE_LIST_C}
index 185e44b5b4a8b0675e920ef0c9483c91bc791f63..6169bd116c74ab880df0fad48ff762265552c423 100644 (file)
@@ -358,7 +358,6 @@ EXTRA_DIST = \
        missing/strsep.c \
        missing/win_ether_ntohost.c \
        missing/win_ether_ntohost.h \
-       missing/win_snprintf.c \
        mkdep \
        packetdat.awk \
        pcap_dump_ftell.c \
index ac79c0f24980224f8810dfcd8c89642f3871de81..effc09144da68ece65b279965edf571fc927a9fd 100644 (file)
@@ -594,7 +594,7 @@ etheraddr_string(netdissect_options *ndo, const u_char *ep)
        }
 
        if (!ndo->ndo_nflag) {
-               snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
+               nd_snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
                    tok2str(oui_values, "Unknown", oui));
        } else
                *cp = '\0';
@@ -743,7 +743,7 @@ tcpport_string(netdissect_options *ndo, u_short port)
        tp->addr = i;
        tp->nxt = newhnamemem(ndo);
 
-       (void)snprintf(buf, sizeof(buf), "%u", i);
+       (void)nd_snprintf(buf, sizeof(buf), "%u", i);
        tp->name = strdup(buf);
        if (tp->name == NULL)
                (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
@@ -764,7 +764,7 @@ udpport_string(netdissect_options *ndo, u_short port)
        tp->addr = i;
        tp->nxt = newhnamemem(ndo);
 
-       (void)snprintf(buf, sizeof(buf), "%u", i);
+       (void)nd_snprintf(buf, sizeof(buf), "%u", i);
        tp->name = strdup(buf);
        if (tp->name == NULL)
                (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
@@ -820,7 +820,7 @@ init_servarray(netdissect_options *ndo)
                while (table->name)
                        table = table->nxt;
                if (ndo->ndo_nflag) {
-                       (void)snprintf(buf, sizeof(buf), "%d", port);
+                       (void)nd_snprintf(buf, sizeof(buf), "%d", port);
                        table->name = strdup(buf);
                } else
                        table->name = strdup(sv->s_name);
@@ -1318,7 +1318,7 @@ const char *
 ieee8021q_tci_string(const uint16_t tci)
 {
        static char buf[128];
-       snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
+       nd_snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
                 tci & 0xfff,
                 tci >> 13,
                 (tci & 0x1000) ? ", DEI" : "");
index 62cc298ae28a0aaa7b501dd0bb71ca00fb8d123c..3b5735291d8cda12a9f6d3849dbf75e62ff1815e 100644 (file)
@@ -191,7 +191,7 @@ addrtostr6 (const void *src, char *dst, size_t size)
       space_left -= added_space;
       break;
     }
-    snprintfed = snprintf (dp, space_left, "%x", words[i]);
+    snprintfed = nd_snprintf (dp, space_left, "%x", words[i]);
     if (snprintfed < 0)
         return (NULL);
     if ((size_t) snprintfed >= space_left)
index 8927a19bad22213e59fb298244b5c19aa1ff9fa2..d54172eef7bb50d32df47688cd5c3e8efcd211ab 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "funcattrs.h"
 
-/* snprintf et al */
-
 #include <stdarg.h>
 
 #if HAVE_STDINT_H
index 0c9304a2ca4ab9adad567d60585138ae781cfbc7..f55c2688190d20cff620a8a5abc1000124af7e57 100644 (file)
--- a/machdep.c
+++ b/machdep.c
 #include <sys/sysinfo.h>
 #include <sys/proc.h>
 
-#if !defined(HAVE_SNPRINTF)
-int snprintf(char *, size_t, const char *, ...) PRINTFLIKE(3, 4);
-#endif /* !defined(HAVE_SNPRINTF) */
-#endif /* __osf__ */
-
 #include "machdep.h"
 
 /*
index 39cee068a69bb6d1e00a72d2d9b6a0c3adde57b7..198644f244036cdc18ade9b027f156eeca9673c1 100644 (file)
@@ -65,9 +65,9 @@ const char *etc_path(const char *file)
         return (file);
     else
 #ifdef _WIN32
-    snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
+    nd_snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
 #else
-    snprintf(path, sizeof(path), "%s%s", env, file);
+    nd_snprintf(path, sizeof(path), "%s%s", env, file);
 #endif
     return (path);
 }
index 921b74c1df3f61159d55042982facf81be2eefe7..3b21f31fbf053970292cb60cf9540ffba0cafb99 100644 (file)
@@ -456,13 +456,13 @@ xyzprintf (struct state *state, const char *char_format, va_list ap)
 
 #ifndef HAVE_SNPRINTF
 int
-snprintf (char *str, size_t sz, const char *format, ...)
+nd_snprintf (char *str, size_t sz, const char *format, ...)
 {
   va_list args;
   int ret;
 
   va_start(args, format);
-  ret = vsnprintf (str, sz, format, args);
+  ret = nd_vsnprintf (str, sz, format, args);
 
 #ifdef PARANOIA
   {
@@ -518,13 +518,13 @@ asprintf (char **ret, const char *format, ...)
 
 #ifndef HAVE_ASNPRINTF
 int
-asnprintf (char **ret, size_t max_sz, const char *format, ...)
+nd_asnprintf (char **ret, size_t max_sz, const char *format, ...)
 {
   va_list args;
   int val;
 
   va_start(args, format);
-  val = vasnprintf (ret, max_sz, format, args);
+  val = nd_vasnprintf (ret, max_sz, format, args);
 
 #ifdef PARANOIA
   {
@@ -550,14 +550,14 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...)
 int
 vasprintf (char **ret, const char *format, va_list args)
 {
-  return vasnprintf (ret, 0, format, args);
+  return nd_vasnprintf (ret, 0, format, args);
 }
 #endif
 
 
 #ifndef HAVE_VASNPRINTF
 int
-vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
+nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
 {
   int st;
   size_t len;
@@ -600,7 +600,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
 
 #ifndef HAVE_VSNPRINTF
 int
-vsnprintf (char *str, size_t sz, const char *format, va_list args)
+nd_vsnprintf (char *str, size_t sz, const char *format, va_list args)
 {
   struct state state;
   int ret;
index 05930923af83612ab303e9aa7c68eff78726c53b..6ac26b7c06152792acc65b1e9a89fe12a5fae585 100644 (file)
@@ -85,9 +85,9 @@ const char *etc_path (const char *file)
     return (file);
 
   if (win9x)
-    snprintf (path, sizeof(path), "%s\\etc\\%s", env, file);
+    nd_snprintf (path, sizeof(path), "%s\\etc\\%s", env, file);
   else
-    snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file);
+    nd_snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file);
 
   return (path);
 }
diff --git a/missing/win_snprintf.c b/missing/win_snprintf.c
deleted file mode 100644 (file)
index 17dc633..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-
-int
-vsnprintf(char *str, size_t str_size, const char *format, va_list args)
-{
-       int ret;
-
-       ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
-
-       /*
-        * XXX - _vsnprintf() and _snprintf() do *not* guarantee
-        * that str is null-terminated, but C99's vsnprintf()
-        * and snprintf() do, and we want to offer C99 behavior,
-        * so forcibly null-terminate the string.
-        */
-       str[str_size - 1] = '\0';
-       return (ret);
-}
-
-int
-snprintf(char *str, size_t str_size, const char *format, ...)
-{
-       va_list args;
-       int ret;
-
-       va_start(args, format);
-       ret = vsnprintf(str, str_size, format, args);
-       va_end(args);
-       return (ret);
-}
index 5437f32ef6d17d7fbc26d721b4a8b83e5bdc3e8a..2a4e1bc781a3c056e92c8a4ce76413e1d8cdbcac 100644 (file)
@@ -307,22 +307,51 @@ typedef char* caddr_t;
  * and define vsnprintf to be _vsnprintf, as we're relying on null-
  * termination of strings in all cases.
  *
- * We also want to allow this to be built with versions of Visual Studio
- * prior to VS 2015, so we can't rely on snprintf() being present.
+ * Furthermore, some versions of Visual Studio prior to Visual
+ * Studio 2015 had vsnprintf() (but not snprintf()!), but those
+ * versions don't guarantee null termination, either.
  *
- * And, if there are any UN*Xes out there on which we can run that
- * don't have snprintf() or don't have vsnprintf(), we define our
- * own as well.
+ * We assume all UN*Xes that have snprintf() and vsnprintf() provide
+ * C99 behavior.
  */
-#if !defined(HAVE_SNPRINTF)
-int snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...)
-     PRINTFLIKE(3, 4);
-#endif /* !defined(HAVE_SNPRINTF) */
-
-#if !defined(HAVE_VSNPRINTF)
-int vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
-     va_list ap) PRINTFLIKE(3, 0);
-#endif /* !defined(HAVE_VSNPRINTF) */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+  #if defined(_MSC_VER) && _MSC_VER >= 1900
+    /*
+     * VS 2015 or newer; just use the C runtime's snprintf() and
+     * vsnprintf().
+     */
+    #define nd_snprintf                snprintf
+    #define nd_vsnprintf       vsnprintf
+  #else /* defined(_MSC_VER) && _MSC_VER >= 1900 */
+    /*
+     * VS prior to 2015, or MingGW; assume we have _snprintf_s() and
+     * _vsnprintf_s(), which guarantee null termination.
+     */
+    #define nd_snprintf(buf, buflen, fmt, ...) \
+        _snprintf_s(buf, buflen, _TRUNCATE, fmt, __VA_ARGS__)
+    #define nd_vsnprintf(buf, buflen, fmt, ap) \
+        _vsnprintf_s(buf, buflen, _TRUNCATE, fmt, ap)
+  #endif /* defined(_MSC_VER) && _MSC_VER >= 1900 */
+#else /* defined(_MSC_VER) || defined(__MINGW32__) */
+  /*
+   * Some other compiler, which we assume to be a UN*X compiler.
+   * Use the system's snprintf() if we have it, otherwise use
+   * our own implementation
+   */
+  #ifdef HAVE_SNPRINTF
+    #define nd_snprintf                snprintf
+  #else /* HAVE_SNPRINTF */
+    int nd_snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...)
+        PRINTFLIKE(3, 4);
+  #endif /* HAVE_SNPRINTF */
+
+  #ifdef HAVE_VSNPRINTF
+    #define nd_vsnprintf       vsnprintf
+  #else /* HAVE_VSNPRINTF */
+    int nd_vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
+        va_list ap) PRINTFLIKE(3, 0);
+  #endif /* HAVE_VSNPRINTF */
+#endif /* defined(_MSC_VER) || defined(__MINGW32__) */
 
 /*
  * fopen() read and write modes for text files and binary files.
index 450bb1a25b973847e7726638b95d6b46dffbc19d..d32de4e97816f8f96acab65397345fe099f7204b 100644 (file)
@@ -122,14 +122,14 @@ nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size)
 {
 #ifdef USE_LIBSMI
        if (smiLoadModule(module) == 0) {
-               snprintf(errbuf, errbuf_size, "could not load MIB module %s",
+               nd_snprintf(errbuf, errbuf_size, "could not load MIB module %s",
                    module);
                return (-1);
        }
        nd_smi_module_loaded = 1;
        return (0);
 #else
-       snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
+       nd_snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
            module);
        return (-1);
 #endif
index 3e76468bd92bf8d8621688ce9f1368630a2be48f..4c09bfe29290fb039c32cf55769c553b3be6f6b2 100644 (file)
@@ -152,7 +152,7 @@ typedef unsigned char nd_mac_addr[MAC_ADDR_LEN];
  */
 typedef unsigned char nd_byte;
 
-/* snprintf et al */
+/* nd_snprintf et al */
 
 #include <stdarg.h>
 #include <pcap.h>
index 0a54a3ff4d2f1217644e71b135ec56ec800f7a2f..324ba664fa3c2fca5e9ced11405b9272cda0adb5 100644 (file)
@@ -450,7 +450,7 @@ Parse_fh(const unsigned char *fh, u_int len, my_fsid *fsidp,
 #endif
            /* Save the actual handle, so it can be display with -u */
            for (i = 0; i < len*4 && i*2 < sizeof(fsidp->Opaque_Handle) - 1; i++)
-               (void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X",
+               (void)nd_snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X",
                               EXTRACT_U_1(fhp + i));
            fsidp->Opaque_Handle[i*2] = '\0';
 
index bd87f6ac7ffb2e03c0eff49661e7002ea7fbaa19..0c347bf08825f33a2f60658bd205a1e82767fa1e 100644 (file)
@@ -114,7 +114,7 @@ hex_and_ascii_print_with_offset(netdissect_options *ndo, const char *ident,
                cp++;
                s2 = EXTRACT_U_1(cp);
                cp++;
-               (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+               (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
                    " %02x%02x", s1, s2);
                hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
                *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
@@ -132,7 +132,7 @@ hex_and_ascii_print_with_offset(netdissect_options *ndo, const char *ident,
        if (length & 1) {
                s1 = EXTRACT_U_1(cp);
                cp++;
-               (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+               (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
                    " %02x", s1);
                hsp += 3;
                *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
index 0d6b87d83faa7f6aee91d10b5c47443697b25306..25a1801a9cba0748c2e081b0a40467e37697a2ee 100644 (file)
@@ -624,7 +624,7 @@ ataddr_string(netdissect_options *ndo,
                if (tp2->addr == i) {
                        tp->addr = (atnet << 8) | athost;
                        tp->nxt = newhnamemem(ndo);
-                       (void)snprintf(nambuf, sizeof(nambuf), "%s.%u",
+                       (void)nd_snprintf(nambuf, sizeof(nambuf), "%s.%u",
                            tp2->name, athost);
                        tp->name = strdup(nambuf);
                        if (tp->name == NULL)
@@ -636,9 +636,9 @@ ataddr_string(netdissect_options *ndo,
        tp->addr = (atnet << 8) | athost;
        tp->nxt = newhnamemem(ndo);
        if (athost != 255)
-               (void)snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost);
+               (void)nd_snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost);
        else
-               (void)snprintf(nambuf, sizeof(nambuf), "%u", atnet);
+               (void)nd_snprintf(nambuf, sizeof(nambuf), "%u", atnet);
        tp->name = strdup(nambuf);
        if (tp->name == NULL)
                (*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
@@ -661,7 +661,7 @@ ddpskt_string(netdissect_options *ndo,
        static char buf[8];
 
        if (ndo->ndo_nflag) {
-               (void)snprintf(buf, sizeof(buf), "%u", skt);
+               (void)nd_snprintf(buf, sizeof(buf), "%u", skt);
                return (buf);
        }
        return (tok2str(skt2str, "%u", skt));
index 0fba820bf1c61bb447a6bbc5b753c1f5782c12f4..c7d789b858e7ceeaa0330e883cecb673f9163c0f 100644 (file)
@@ -111,7 +111,7 @@ static const char *
 format_id(const u_char *id)
 {
     static char buf[25];
-    snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
+    nd_snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
              EXTRACT_U_1(id), EXTRACT_U_1(id + 1), EXTRACT_U_1(id + 2),
              EXTRACT_U_1(id + 3), EXTRACT_U_1(id + 4), EXTRACT_U_1(id + 5),
              EXTRACT_U_1(id + 6), EXTRACT_U_1(id + 7));
@@ -127,9 +127,9 @@ format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
 {
     static char buf[50];
     if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
-        snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
+        nd_snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
     else
-        snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
+        nd_snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
     buf[49] = '\0';
     return buf;
 }
@@ -150,7 +150,7 @@ format_interval(const uint16_t i)
 
     if (i == 0)
         return "0.0s (bogus)";
-    snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
+    nd_snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
     return buf;
 }
 
@@ -164,7 +164,7 @@ static const char *
 format_timestamp(const uint32_t i)
 {
     static char buf[sizeof("0000.000000s")];
-    snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+    nd_snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
     return buf;
 }
 
index 5a8f279e6596b387d43b402a1acf40d502484bc6..dd1f6d38ce15ed3674a28116af3eeb9d9c9f3d6d 100644 (file)
@@ -524,9 +524,9 @@ as_printf(netdissect_options *ndo,
           char *str, size_t size, u_int asnum)
 {
     if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
-        snprintf(str, size, "%u", asnum);
+        nd_snprintf(str, size, "%u", asnum);
     } else {
-        snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
+        nd_snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
     }
     return str;
 }
@@ -555,7 +555,7 @@ decode_prefix4(netdissect_options *ndo,
     if (plen % 8) {
         ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
     }
-    snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, &addr), plen);
+    nd_snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, &addr), plen);
     return 1 + plenbytes;
 
 trunc:
@@ -603,7 +603,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
         ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
     }
     /* the label may get offsetted by 4 bits so lets shift it right */
-    snprintf(buf, buflen, "%s/%u, label:%u %s",
+    nd_snprintf(buf, buflen, "%s/%u, label:%u %s",
              ipaddr_string(ndo, &addr),
              plen,
              EXTRACT_BE_U_3(pptr + 1)>>4,
@@ -635,14 +635,14 @@ bgp_vpn_ip_print(netdissect_options *ndo,
     switch(addr_length) {
     case (sizeof(struct in_addr) << 3): /* 32 */
         ND_TCHECK_LEN(pptr, sizeof(struct in_addr));
-        snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
+        nd_snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
         break;
     case (sizeof(struct in6_addr) << 3): /* 128 */
         ND_TCHECK_LEN(pptr, sizeof(struct in6_addr));
-        snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
+        nd_snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
         break;
     default:
-        snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
+        nd_snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
         break;
     }
     pos += strlen(pos);
@@ -689,7 +689,7 @@ bgp_vpn_sg_print(netdissect_options *ndo,
     total_length += (addr_length >> 3) + 1;
     offset = strlen(buf);
     if (addr_length) {
-        snprintf(buf + offset, buflen - offset, ", Source %s",
+        nd_snprintf(buf + offset, buflen - offset, ", Source %s",
              bgp_vpn_ip_print(ndo, pptr, addr_length));
         pptr += (addr_length >> 3);
     }
@@ -704,7 +704,7 @@ bgp_vpn_sg_print(netdissect_options *ndo,
     total_length += (addr_length >> 3) + 1;
     offset = strlen(buf);
     if (addr_length) {
-        snprintf(buf + offset, buflen - offset, ", Group %s",
+        nd_snprintf(buf + offset, buflen - offset, ", Group %s",
              bgp_vpn_ip_print(ndo, pptr, addr_length));
         pptr += (addr_length >> 3);
     }
@@ -729,7 +729,7 @@ bgp_vpn_rd_print(netdissect_options *ndo,
 
         /* 2-byte-AS:number fmt*/
     case 0:
-        snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)",
+        nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)",
                  EXTRACT_BE_U_2(pptr + 2),
                  EXTRACT_BE_U_4(pptr + 4),
                  EXTRACT_U_1(pptr + 4), EXTRACT_U_1(pptr + 5),
@@ -738,7 +738,7 @@ bgp_vpn_rd_print(netdissect_options *ndo,
         /* IP-address:AS fmt*/
 
     case 1:
-        snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u",
+        nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u",
                  EXTRACT_U_1(pptr + 2), EXTRACT_U_1(pptr + 3),
                  EXTRACT_U_1(pptr + 4), EXTRACT_U_1(pptr + 5),
                  EXTRACT_BE_U_2(pptr + 6));
@@ -746,14 +746,14 @@ bgp_vpn_rd_print(netdissect_options *ndo,
 
         /* 4-byte-AS:number fmt*/
     case 2:
-        snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
+        nd_snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
                  as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(pptr + 2)),
                  EXTRACT_BE_U_2(pptr + 6), EXTRACT_U_1(pptr + 2),
                  EXTRACT_U_1(pptr + 3), EXTRACT_U_1(pptr + 4),
                  EXTRACT_U_1(pptr + 5), EXTRACT_BE_U_2(pptr + 6));
         break;
     default:
-        snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
+        nd_snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
         break;
     }
     pos += strlen(pos);
@@ -779,7 +779,7 @@ decode_rt_routing_info(netdissect_options *ndo,
      */
     if (0 == plen) {
         /* Without "origin AS", without "route target". */
-        snprintf(buf, buflen, "default route target");
+        nd_snprintf(buf, buflen, "default route target");
         return 1;
     }
 
@@ -807,7 +807,7 @@ decode_rt_routing_info(netdissect_options *ndo,
         ((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
             ((0xff00 >> (plen % 8)) & 0xff);
     }
-    snprintf(buf, buflen, "origin AS: %s, route target %s",
+    nd_snprintf(buf, buflen, "origin AS: %s, route target %s",
              asbuf,
              bgp_vpn_rd_print(ndo, (u_char *)&route_target));
 
@@ -843,7 +843,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo,
             ((0xff00 >> (plen % 8)) & 0xff);
     }
     /* the label may get offsetted by 4 bits so lets shift it right */
-    snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+    nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
              bgp_vpn_rd_print(ndo, pptr+4),
              ipaddr_string(ndo, &addr),
              plen,
@@ -895,7 +895,7 @@ decode_mdt_vpn_nlri(netdissect_options *ndo,
     /* MDT Group Address */
     ND_TCHECK_LEN(pptr, sizeof(struct in_addr));
 
-    snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
+    nd_snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
              bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
 
     return MDT_VPN_NLRI_LEN + 1;
@@ -937,7 +937,7 @@ decode_multicast_vpn(netdissect_options *ndo,
     route_length = EXTRACT_U_1(pptr);
     pptr++;
 
-    snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
+    nd_snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
          tok2str(bgp_multicast_vpn_route_type_values,
                  "Unknown", route_type),
          route_type, route_length);
@@ -946,7 +946,7 @@ decode_multicast_vpn(netdissect_options *ndo,
     case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
         ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
+        nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
                  bgp_vpn_rd_print(ndo, pptr),
                  bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN,
                                   (route_length - BGP_VPN_RD_LEN) << 3));
@@ -954,7 +954,7 @@ decode_multicast_vpn(netdissect_options *ndo,
     case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
         ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+        nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
         bgp_vpn_rd_print(ndo, pptr),
         as_printf(ndo, astostr, sizeof(astostr),
         EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
@@ -963,7 +963,7 @@ decode_multicast_vpn(netdissect_options *ndo,
     case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
         ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", RD: %s",
+        nd_snprintf(buf + offset, buflen - offset, ", RD: %s",
                  bgp_vpn_rd_print(ndo, pptr));
         pptr += BGP_VPN_RD_LEN;
 
@@ -972,14 +972,14 @@ decode_multicast_vpn(netdissect_options *ndo,
 
         ND_TCHECK_LEN(pptr, addr_length);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", Originator %s",
+        nd_snprintf(buf + offset, buflen - offset, ", Originator %s",
                  bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
         break;
 
     case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
         ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", RD: %s",
+        nd_snprintf(buf + offset, buflen - offset, ", RD: %s",
                  bgp_vpn_rd_print(ndo, pptr));
         pptr += BGP_VPN_RD_LEN;
 
@@ -990,7 +990,7 @@ decode_multicast_vpn(netdissect_options *ndo,
     case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
         ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN + 4);
         offset = strlen(buf);
-        snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+        nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
                  bgp_vpn_rd_print(ndo, pptr),
                  as_printf(ndo, astostr, sizeof(astostr),
                  EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
@@ -1052,7 +1052,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
         /* assume AD-only with RD, BGPNH */
         ND_TCHECK_LEN(pptr, 12);
         buf[0] = '\0';
-        stringlen = snprintf(buf, buflen, "RD: %s, BGPNH: %s",
+        stringlen = nd_snprintf(buf, buflen, "RD: %s, BGPNH: %s",
                              bgp_vpn_rd_print(ndo, pptr),
                              ipaddr_string(ndo, pptr+8));
         UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
@@ -1065,7 +1065,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
 
         ND_TCHECK_LEN(pptr, 15);
         buf[0] = '\0';
-        stringlen = snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
+        stringlen = nd_snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
                              bgp_vpn_rd_print(ndo, pptr),
                              EXTRACT_BE_U_2(pptr + 8),
                              EXTRACT_BE_U_2(pptr + 10),
@@ -1078,7 +1078,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
         while (tlen != 0) {
             if (tlen < 3) {
                 if (buflen != 0) {
-                    stringlen=snprintf(buf,buflen, "\n\t\tran past the end");
+                    stringlen=nd_snprintf(buf,buflen, "\n\t\tran past the end");
                     UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                 }
                 return plen + 2;
@@ -1093,7 +1093,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
             switch(tlv_type) {
             case 1:
                 if (buflen != 0) {
-                    stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
+                    stringlen=nd_snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
                                        tlv_type,
                                        tlv_len);
                     UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
@@ -1101,14 +1101,14 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                 while (ttlv_len != 0) {
                     if (tlen < 1) {
                         if (buflen != 0) {
-                            stringlen=snprintf(buf,buflen, " (ran past the end)");
+                            stringlen=nd_snprintf(buf,buflen, " (ran past the end)");
                             UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                         }
                         return plen + 2;
                     }
                     ND_TCHECK_1(pptr);
                     if (buflen != 0) {
-                        stringlen=snprintf(buf,buflen, "%02x",
+                        stringlen=nd_snprintf(buf,buflen, "%02x",
                                            EXTRACT_U_1(pptr));
                         pptr++;
                         UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
@@ -1119,14 +1119,14 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                 break;
             default:
                 if (buflen != 0) {
-                    stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
+                    stringlen=nd_snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
                                        tlv_type,
                                        tlv_len);
                     UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                 }
                 if (tlen < ttlv_len) {
                     if (buflen != 0) {
-                        stringlen=snprintf(buf,buflen, " (ran past the end)");
+                        stringlen=nd_snprintf(buf,buflen, " (ran past the end)");
                         UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                     }
                     return plen + 2;
@@ -1169,7 +1169,7 @@ decode_prefix6(netdissect_options *ndo,
         addr.s6_addr[plenbytes - 1] &=
             ((0xff00 >> (plen % 8)) & 0xff);
     }
-    snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, &addr), plen);
+    nd_snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, &addr), plen);
     return 1 + plenbytes;
 
 trunc:
@@ -1209,7 +1209,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
             ((0xff00 >> (plen % 8)) & 0xff);
     }
     /* the label may get offsetted by 4 bits so lets shift it right */
-    snprintf(buf, buflen, "%s/%u, label:%u %s",
+    nd_snprintf(buf, buflen, "%s/%u, label:%u %s",
              ip6addr_string(ndo, &addr),
              plen,
              EXTRACT_BE_U_3(pptr + 1)>>4,
@@ -1250,7 +1250,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
             ((0xff00 >> (plen % 8)) & 0xff);
     }
     /* the label may get offsetted by 4 bits so lets shift it right */
-    snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+    nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
              bgp_vpn_rd_print(ndo, pptr+4),
              ip6addr_string(ndo, &addr),
              plen,
@@ -1283,7 +1283,7 @@ decode_clnp_prefix(netdissect_options *ndo,
         addr[(plen + 7) / 8 - 1] &=
             ((0xff00 >> (plen % 8)) & 0xff);
     }
-    snprintf(buf, buflen, "%s/%u",
+    nd_snprintf(buf, buflen, "%s/%u",
              isonsap_string(ndo, addr,(plen + 7) / 8),
              plen);
 
@@ -1318,7 +1318,7 @@ decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
         addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff);
     }
     /* the label may get offsetted by 4 bits so lets shift it right */
-    snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
+    nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s",
              bgp_vpn_rd_print(ndo, pptr+4),
              isonsap_string(ndo, addr,(plen + 7) / 8),
              plen,
index 17fdc8594dc11dca4cf17b78c6083512cccb4df4..badbea96bfbbe7492d5c8e25dde725b67d77ad60 100644 (file)
@@ -296,14 +296,14 @@ cnfp_v5_print(netdissect_options *ndo, const u_char *cp)
                       EXTRACT_BE_U_4(nr->last_time)%1000);
 
                asbuf[0] = buf[0] = '\0';
-               snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
-               snprintf(asbuf, sizeof(asbuf), ":%u",
+               nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
+               nd_snprintf(asbuf, sizeof(asbuf), ":%u",
                        EXTRACT_BE_U_2(nr->src_as));
                ND_PRINT("\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
                        EXTRACT_BE_U_2(nr->srcport));
 
-               snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
-               snprintf(asbuf, sizeof(asbuf), ":%u",
+               nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
+               nd_snprintf(asbuf, sizeof(asbuf), ":%u",
                         EXTRACT_BE_U_2(nr->dst_as));
                ND_PRINT("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
                        EXTRACT_BE_U_2(nr->dstport));
@@ -394,14 +394,14 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
                       EXTRACT_BE_U_4(nr->last_time)%1000);
 
                asbuf[0] = buf[0] = '\0';
-               snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
-               snprintf(asbuf, sizeof(asbuf), ":%u",
+               nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->src_mask));
+               nd_snprintf(asbuf, sizeof(asbuf), ":%u",
                        EXTRACT_BE_U_2(nr->src_as));
                ND_PRINT("\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
                        EXTRACT_BE_U_2(nr->srcport));
 
-               snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
-               snprintf(asbuf, sizeof(asbuf), ":%u",
+               nd_snprintf(buf, sizeof(buf), "/%u", EXTRACT_U_1(nr->dst_mask));
+               nd_snprintf(asbuf, sizeof(asbuf), ":%u",
                         EXTRACT_BE_U_2(nr->dst_as));
                ND_PRINT("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
                        EXTRACT_BE_U_2(nr->dstport));
@@ -429,7 +429,7 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
                }
 
                buf[0]='\0';
-               snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
+               nd_snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
                         (EXTRACT_BE_U_2(nr->flags) >> 8) & 0xff,
                         (EXTRACT_BE_U_2(nr->flags)) & 0xff);
                ND_PRINT("tos %u, %u (%u octets) %s",
index 7606d5c2f159b53fbc9f2717bf701066ee3056a9..92361cf3e902db5f22562a65b3c5740a9bd8c0ef 100644 (file)
@@ -1246,7 +1246,7 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
        str = (char *)malloc(siz = sizeof("00.0000"));
        if (str == NULL)
                (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
-       snprintf(str, siz, "%u.%u", area, node);
+       nd_snprintf(str, siz, "%u.%u", area, node);
        return(str);
 }
 
index d9ac455bc7f22c09f504a08be47f3ea432e5fa36..a95b56f2db559247c1123a70dbbc9a122abb041e 100644 (file)
@@ -152,7 +152,7 @@ q922_string(netdissect_options *ndo, const u_char *p, u_int length)
     memset(buffer, 0, sizeof(buffer));
 
     if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
-        snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
+        nd_snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
     }
 
     return buffer;
index 0dee297f4cad9ae71f4a1b60aa67ae0c9b747672..1121d2a19666d61dcdad147b1d6b40b564502bf1 100644 (file)
@@ -161,7 +161,7 @@ format_nid(const u_char *data)
     static char buf[4][sizeof("01:01:01:01")];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
+    nd_snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
              EXTRACT_U_1(data), EXTRACT_U_1(data + 1), EXTRACT_U_1(data + 2),
              EXTRACT_U_1(data + 3));
     return buf[i];
@@ -173,7 +173,7 @@ format_256(const u_char *data)
     static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
+    nd_snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
          EXTRACT_BE_U_8(data),
          EXTRACT_BE_U_8(data + 8),
          EXTRACT_BE_U_8(data + 16),
@@ -188,7 +188,7 @@ format_interval(const uint32_t n)
     static char buf[4][sizeof("0000000.000s")];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
+    nd_snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
     return buf[i];
 }
 
@@ -226,7 +226,7 @@ print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length)
                ((u_char *)&addr)[plenbytes - 1] &=
                        ((0xff00 >> (plen % 8)) & 0xff);
        }
-       snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, &addr), plen);
+       nd_snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, &addr), plen);
         plenbytes += 1 + IPV4_MAPPED_HEADING_LEN;
     } else {
         plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf));
index 7e7db14a7fef6e2f8caa2e5c7bd4506e0ad29cdf..269b14fbd8f7e86bc02321dbc52bf706419ef0a7 100644 (file)
@@ -322,7 +322,7 @@ icmp_tstamp_print(u_int tstamp)
     sec = tstamp / 1000;
     min = sec / 60; sec -= min * 60;
     hrs = min / 60; min -= hrs * 60;
-    snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
+    nd_snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
     return buf;
 }
 
@@ -360,7 +360,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
        case ICMP_ECHO:
        case ICMP_ECHOREPLY:
                ND_TCHECK_2(dp->icmp_seq);
-               (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
+               (void)nd_snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
                                icmp_type == ICMP_ECHO ?
                                "request" : "reply",
                                EXTRACT_BE_U_2(dp->icmp_id),
@@ -373,7 +373,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 
                case ICMP_UNREACH_PROTOCOL:
                        ND_TCHECK_1(dp->icmp_ip.ip_p);
-                       (void)snprintf(buf, sizeof(buf),
+                       (void)nd_snprintf(buf, sizeof(buf),
                            "%s protocol %u unreachable",
                            ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
                            EXTRACT_U_1(dp->icmp_ip.ip_p));
@@ -390,21 +390,21 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        switch (ip_proto) {
 
                        case IPPROTO_TCP:
-                               (void)snprintf(buf, sizeof(buf),
+                               (void)nd_snprintf(buf, sizeof(buf),
                                        "%s tcp port %s unreachable",
                                        ipaddr_string(ndo, &oip->ip_dst),
                                        tcpport_string(ndo, dport));
                                break;
 
                        case IPPROTO_UDP:
-                               (void)snprintf(buf, sizeof(buf),
+                               (void)nd_snprintf(buf, sizeof(buf),
                                        "%s udp port %s unreachable",
                                        ipaddr_string(ndo, &oip->ip_dst),
                                        udpport_string(ndo, dport));
                                break;
 
                        default:
-                               (void)snprintf(buf, sizeof(buf),
+                               (void)nd_snprintf(buf, sizeof(buf),
                                        "%s protocol %u port %u unreachable",
                                        ipaddr_string(ndo, &oip->ip_dst),
                                        ip_proto, dport);
@@ -418,11 +418,11 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void;
                        mtu = EXTRACT_BE_U_2(mp->nexthopmtu);
                        if (mtu) {
-                               (void)snprintf(buf, sizeof(buf),
+                               (void)nd_snprintf(buf, sizeof(buf),
                                    "%s unreachable - need to frag (mtu %u)",
                                    ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu);
                        } else {
-                               (void)snprintf(buf, sizeof(buf),
+                               (void)nd_snprintf(buf, sizeof(buf),
                                    "%s unreachable - need to frag",
                                    ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
                        }
@@ -432,7 +432,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                default:
                        fmt = tok2str(unreach2str, "#%u %%s unreachable",
                            icmp_code);
-                       (void)snprintf(buf, sizeof(buf), fmt,
+                       (void)nd_snprintf(buf, sizeof(buf), fmt,
                            ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
                        break;
                }
@@ -442,7 +442,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                ND_TCHECK_4(dp->icmp_ip.ip_dst);
                fmt = tok2str(type2str, "redirect-#%u %%s to net %%s",
                    icmp_code);
-               (void)snprintf(buf, sizeof(buf), fmt,
+               (void)nd_snprintf(buf, sizeof(buf), fmt,
                    ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
                    ipaddr_string(ndo, &dp->icmp_gwaddr));
                break;
@@ -453,7 +453,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                const struct id_rdiscovery *idp;
                u_int lifetime, num, size;
 
-               (void)snprintf(buf, sizeof(buf), "router advertisement");
+               (void)nd_snprintf(buf, sizeof(buf), "router advertisement");
                cp = buf + strlen(buf);
 
                ihp = (const struct ih_rdiscovery *)&dp->icmp_void;
@@ -462,13 +462,13 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                cp = buf + strlen(buf);
                lifetime = EXTRACT_BE_U_2(ihp->ird_lifetime);
                if (lifetime < 60) {
-                       (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
+                       (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u",
                            lifetime);
                } else if (lifetime < 60 * 60) {
-                       (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
+                       (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
                            lifetime / 60, lifetime % 60);
                } else {
-                       (void)snprintf(cp, sizeof(buf) - (cp - buf),
+                       (void)nd_snprintf(cp, sizeof(buf) - (cp - buf),
                            "%u:%02u:%02u",
                            lifetime / 3600,
                            (lifetime % 3600) / 60,
@@ -477,19 +477,19 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                cp = buf + strlen(buf);
 
                num = EXTRACT_U_1(ihp->ird_addrnum);
-               (void)snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num);
+               (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num);
                cp = buf + strlen(buf);
 
                size = EXTRACT_U_1(ihp->ird_addrsiz);
                if (size != 2) {
-                       (void)snprintf(cp, sizeof(buf) - (cp - buf),
+                       (void)nd_snprintf(cp, sizeof(buf) - (cp - buf),
                            " [size %u]", size);
                        break;
                }
                idp = (const struct id_rdiscovery *)&dp->icmp_data;
                while (num-- > 0) {
                        ND_TCHECK_SIZE(idp);
-                       (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
+                       (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
                            ipaddr_string(ndo, &idp->ird_addr),
                            EXTRACT_BE_U_4(idp->ird_pref));
                        cp = buf + strlen(buf);
@@ -511,7 +511,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        break;
 
                default:
-                       (void)snprintf(buf, sizeof(buf), "time exceeded-#%u",
+                       (void)nd_snprintf(buf, sizeof(buf), "time exceeded-#%u",
                            icmp_code);
                        break;
                }
@@ -519,24 +519,24 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 
        case ICMP_PARAMPROB:
                if (icmp_code)
-                       (void)snprintf(buf, sizeof(buf),
+                       (void)nd_snprintf(buf, sizeof(buf),
                            "parameter problem - code %u", icmp_code);
                else {
                        ND_TCHECK_1(dp->icmp_pptr);
-                       (void)snprintf(buf, sizeof(buf),
+                       (void)nd_snprintf(buf, sizeof(buf),
                            "parameter problem - octet %u", EXTRACT_U_1(dp->icmp_pptr));
                }
                break;
 
        case ICMP_MASKREPLY:
                ND_TCHECK_4(dp->icmp_mask);
-               (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
+               (void)nd_snprintf(buf, sizeof(buf), "address mask is 0x%08x",
                    EXTRACT_BE_U_4(dp->icmp_mask));
                break;
 
        case ICMP_TSTAMP:
                ND_TCHECK_2(dp->icmp_seq);
-               (void)snprintf(buf, sizeof(buf),
+               (void)nd_snprintf(buf, sizeof(buf),
                    "time stamp query id %u seq %u",
                    EXTRACT_BE_U_2(dp->icmp_id),
                    EXTRACT_BE_U_2(dp->icmp_seq));
@@ -544,15 +544,15 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 
        case ICMP_TSTAMPREPLY:
                ND_TCHECK_4(dp->icmp_ttime);
-               (void)snprintf(buf, sizeof(buf),
+               (void)nd_snprintf(buf, sizeof(buf),
                    "time stamp reply id %u seq %u: org %s",
                                EXTRACT_BE_U_2(dp->icmp_id),
                                EXTRACT_BE_U_2(dp->icmp_seq),
                                icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_otime)));
 
-                (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s",
+                (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s",
                          icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_rtime)));
-                (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s",
+                (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s",
                          icmp_tstamp_print(EXTRACT_BE_U_4(dp->icmp_ttime)));
                 break;
 
index 9d073edc1f6806059cefc4bd53a5350206248da4..9453ce9b73e0cfec44b0bffccb96ccd60819b2bd 100644 (file)
@@ -755,7 +755,7 @@ get_lifetime(uint32_t v)
        if (v == (uint32_t)~0UL)
                return "infinity";
        else {
-               snprintf(buf, sizeof(buf), "%us", v);
+               nd_snprintf(buf, sizeof(buf), "%us", v);
                return buf;
        }
 }
index 4af8b0ebd3027a47c4c04ae214e3913a8612ffd3..4faebf733538ae0ca8cd7051f031b96360b358ab 100644 (file)
@@ -100,7 +100,7 @@ ipxaddr_string(uint32_t net, const u_char *node)
 {
     static char line[256];
 
-    snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x",
+    nd_snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x",
            net, EXTRACT_U_1(node), EXTRACT_U_1(node + 1),
            EXTRACT_U_1(node + 2), EXTRACT_U_1(node + 3),
            EXTRACT_U_1(node + 4), EXTRACT_U_1(node + 5));
index df9eaf92e94c553c6525f02fc0d3a727d6357736..84229ec5c2b19de8127234de1e715b9c1a6de69e 100644 (file)
@@ -2794,7 +2794,7 @@ static char *
 numstr(u_int x)
 {
        static char buf[20];
-       snprintf(buf, sizeof(buf), "#%u", x);
+       nd_snprintf(buf, sizeof(buf), "#%u", x);
        return buf;
 }
 
index 6433e0121818dde7823dd62600faa494881b66b8..b8252301d3b029e644b85908a305781c16b74105 100644 (file)
@@ -1676,19 +1676,19 @@ isis_print_id(const uint8_t *cp, u_int id_len)
     if (sysid_len > id_len)
         sysid_len = id_len;
     for (i = 1; i <= sysid_len; i++) {
-        snprintf(pos, sizeof(id) - (pos - id), "%02x", EXTRACT_U_1(cp));
+        nd_snprintf(pos, sizeof(id) - (pos - id), "%02x", EXTRACT_U_1(cp));
        cp++;
        pos += strlen(pos);
        if (i == 2 || i == 4)
            *pos++ = '.';
        }
     if (id_len >= NODE_ID_LEN) {
-        snprintf(pos, sizeof(id) - (pos - id), ".%02x", EXTRACT_U_1(cp));
+        nd_snprintf(pos, sizeof(id) - (pos - id), ".%02x", EXTRACT_U_1(cp));
        cp++;
        pos += strlen(pos);
     }
     if (id_len == LSP_ID_LEN)
-        snprintf(pos, sizeof(id) - (pos - id), "-%02x", EXTRACT_U_1(cp));
+        nd_snprintf(pos, sizeof(id) - (pos - id), "-%02x", EXTRACT_U_1(cp));
     return (id);
 }
 
@@ -1878,7 +1878,7 @@ isis_print_ext_is_reach(netdissect_options *ndo,
     if (subtlv_sum_len) {
         ND_PRINT(" (%u)", subtlv_sum_len);
         /* prepend the indent string */
-        snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
+        nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
         ident = ident_buffer;
         while (subtlv_sum_len != 0) {
             if (!ND_TTEST_2(tptr))
@@ -2214,7 +2214,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
             subtlvlen=EXTRACT_U_1(tptr + 1);
             tptr+=2;
             /* prepend the indent string */
-            snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
+            nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
             if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
                 return(0);
             tptr+=subtlvlen;
index 1fdb8f254335947a373ce6ef7c713e246834bd68..e76260eccb50489d08f7636ce2020d90120abd9c 100644 (file)
@@ -1355,10 +1355,10 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
     }
 
     if (!pfunc) {
-        snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
+        nd_snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
                  tok2str(af_values, "Unknown", af), af);
     } else {
-        snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
+        nd_snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
                  tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
     }
 
index 3407961f4000f41d05243bee91eec6554fc06a16..85540693dc79dfbf43060364e06d2d8fee2f930e 100644 (file)
@@ -332,11 +332,11 @@ nfsreply_print(netdissect_options *ndo,
        ND_TCHECK_4(rp->rm_xid);
        if (!ndo->ndo_nflag) {
                strlcpy(srcid, "nfs", sizeof(srcid));
-               snprintf(dstid, sizeof(dstid), "%u",
+               nd_snprintf(dstid, sizeof(dstid), "%u",
                    EXTRACT_BE_U_4(rp->rm_xid));
        } else {
-               snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
-               snprintf(dstid, sizeof(dstid), "%u",
+               nd_snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
+               nd_snprintf(dstid, sizeof(dstid), "%u",
                    EXTRACT_BE_U_4(rp->rm_xid));
        }
        print_nfsaddr(ndo, bp2, srcid, dstid);
index ac58d7b3f8529bf1489b0a94161a2450395b4d7e..9004f927ef8dfe1a12712d050359043cc88af926 100644 (file)
@@ -703,7 +703,7 @@ vlan_str(const uint16_t vid)
        if (vid == OFP_VLAN_NONE)
                return "NONE";
        fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
-       snprintf(buf, sizeof(buf), fmt, vid);
+       nd_snprintf(buf, sizeof(buf), fmt, vid);
        return buf;
 }
 
@@ -711,7 +711,7 @@ static const char *
 pcp_str(const uint8_t pcp)
 {
        static char buf[sizeof("255 (bogus)")];
-       snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
+       nd_snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
        return buf;
 }
 
index 150ee9712c5dcce9aed7e581216d3a608789c608..ca6b467274202f18fcc98d8c2a888c6efe2f3848 100644 (file)
@@ -1184,7 +1184,7 @@ acl_print(netdissect_options *ndo,
                  acl & PRSFS_ADMINISTER ? "a" : "");
 
        for (i = 0; i < pos; i++) {
-               snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+               nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
                if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
                        goto finish;
                s += n;
@@ -1198,7 +1198,7 @@ acl_print(netdissect_options *ndo,
        }
 
        for (i = 0; i < neg; i++) {
-               snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+               nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
                if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
                        goto finish;
                s += n;
index b9c71fb0de09a99a0d1fc770101f46122c24ecbb..91136796b2a8b713f0cad749312178cb1a1acb54 100644 (file)
@@ -198,7 +198,7 @@ static const char *ErrorStatus[] = {
 #define DECODE_ErrorStatus(e) \
        ( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
                ? ErrorStatus[e] \
-               : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
+               : (nd_snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
 
 /*
  * generic-trap values in the SNMP Trap-PDU
@@ -216,7 +216,7 @@ static const char *GenericTrap[] = {
 #define DECODE_GenericTrap(t) \
        ( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
                ? GenericTrap[t] \
-               : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
+               : (nd_snprintf(buf, sizeof(buf), "gt=%d", t), buf))
 
 /*
  * ASN.1 type class table
index 0ccfc411c2b48b3cb5a1110268a253432acf80ee..f0fecaf748e683b69873f8055eb81d28e0ea4f76 100644 (file)
@@ -91,7 +91,7 @@ stp_print_bridge_id(const u_char *p)
 {
     static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")];
 
-    snprintf(bridge_id_str, sizeof(bridge_id_str),
+    nd_snprintf(bridge_id_str, sizeof(bridge_id_str),
              "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
              EXTRACT_U_1(p), EXTRACT_U_1(p + 1), EXTRACT_U_1(p + 2),
              EXTRACT_U_1(p + 3), EXTRACT_U_1(p + 4), EXTRACT_U_1(p + 5),
index 749abd1f361311ca62525760a1ff3fb7bd01156b..74e9db384da130bd7a0b6869743972dd5810cee3 100644 (file)
@@ -170,13 +170,13 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp,
        rp = (const struct sunrpc_msg *)bp;
 
        if (!ndo->ndo_nflag) {
-               snprintf(srcid, sizeof(srcid), "0x%x",
+               nd_snprintf(srcid, sizeof(srcid), "0x%x",
                    EXTRACT_BE_U_4(rp->rm_xid));
                strlcpy(dstid, "sunrpc", sizeof(dstid));
        } else {
-               snprintf(srcid, sizeof(srcid), "0x%x",
+               nd_snprintf(srcid, sizeof(srcid), "0x%x",
                    EXTRACT_BE_U_4(rp->rm_xid));
-               snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
+               nd_snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
        }
 
        switch (IP_V((const struct ip *)bp2)) {
@@ -234,7 +234,7 @@ progstr(uint32_t prog)
        rp = getrpcbynumber(prog);
        if (rp == NULL)
 #endif
-               (void) snprintf(buf, sizeof(buf), "#%u", prog);
+               (void) nd_snprintf(buf, sizeof(buf), "#%u", prog);
 #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
        else
                strlcpy(buf, rp->r_name, sizeof(buf));
index f23d8a56739cb5df46322ec57c52e0eaa95dcb90..6c3e7d532c17470a15fd1dd50b490f1e159f41f8 100644 (file)
@@ -382,7 +382,7 @@ numstr(int x)
 {
        static char buf[20];
 
-       snprintf(buf, sizeof(buf), "%#x", x);
+       nd_snprintf(buf, sizeof(buf), "%#x", x);
        return buf;
 }
 
index 01e34ed8aa92b422a9cca7320b4f95db6b05fe2a..eddbe8598fb43895254712e33788b88fc9fc6893 100644 (file)
@@ -119,7 +119,7 @@ z_triple(const char *class, const char *inst, const char *recipient)
 {
     if (!*recipient)
        recipient = "*";
-    snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient);
+    nd_snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient);
     z_buf[sizeof(z_buf)-1] = '\0';
     return z_buf;
 }
index 01f21fe661a84d7bce6420a73edaabd4088a679e..c2249c451759ccce919b4257d62b8752c9fe3709 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -1026,17 +1026,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 +1917,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;
 }
index b325b28c116b45f05b8ce3e70574c9c8660fa27f..81321f7967c68788b3fb2807e86dc773fba593c4 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -779,7 +779,7 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
        if (cnt == 0 && max_chars == 0)
                strncpy(buffer, filename, PATH_MAX + 1);
        else
-               if (snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
+               if (nd_snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
                   /* Report an error if the filename is too large */
                   error("too many output files or filename is too long (> %d)", PATH_MAX);
         free(filename);
@@ -1198,7 +1198,7 @@ fprintf(stderr, "Opening %s\n", device);
                        /*
                         * Return an error for our caller to handle.
                         */
-                       snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
+                       nd_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
                            device, pcap_statustostr(status), cp);
                        pcap_close(pc);
                        return (NULL);
@@ -1212,7 +1212,7 @@ fprintf(stderr, "Opening %s\n", device);
                        char sysctl[32];
                        size_t s = sizeof(parent);
 
-                       snprintf(sysctl, sizeof(sysctl),
+                       nd_snprintf(sysctl, sizeof(sysctl),
                            "net.wlan.%d.%%parent", atoi(device + 4));
                        sysctlbyname(sysctl, parent, &s, NULL, 0);
                        strlcpy(newdev, device, sizeof(newdev));
index 82f450c67ea2de3c61b259ea8db57e35066198ab..5123ba1ab9a1c2f0493f13e1f6cf679c070146a2 100644 (file)
@@ -268,7 +268,7 @@ _U_
        format = "%02d:%02d:%02d.%06u";
 #endif
 
-       snprintf(buf, TS_BUF_SIZE, format,
+       nd_snprintf(buf, TS_BUF_SIZE, format,
                  sec / 3600, (sec % 3600) / 60, sec % 60, usec);
 
         return buf;
@@ -305,7 +305,7 @@ _U_
        format = "%u.%06u";
 #endif
 
-       snprintf(buf, TS_BUF_SIZE, format,
+       nd_snprintf(buf, TS_BUF_SIZE, format,
                 (unsigned)sec, (unsigned)usec);
 
        return buf;
@@ -497,7 +497,7 @@ tok2strbuf(const struct tok *lp, const char *fmt,
        if (fmt == NULL)
                fmt = "#%d";
 
-       (void)snprintf(buf, bufsize, fmt, v);
+       (void)nd_snprintf(buf, bufsize, fmt, v);
        return (const char *)buf;
 }
 
@@ -569,7 +569,7 @@ bittok2str_internal(const struct tok *lp, const char *fmt,
 
         if (bufp == buf)
             /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
-            (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
+            (void)nd_snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
         return (buf);
 }
 
@@ -611,7 +611,7 @@ tok2strary_internal(const char **lp, int n, const char *fmt,
                return lp[v];
        if (fmt == NULL)
                fmt = "#%d";
-       (void)snprintf(buf, sizeof(buf), fmt, v);
+       (void)nd_snprintf(buf, sizeof(buf), fmt, v);
        return (buf);
 }