diff options
40 files changed, 189 insertions, 412 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 08d2d249..1c5f80da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,37 +278,28 @@ else(STDLIBS_HAVE_GETSERVENT) endif(STDLIBS_HAVE_GETSERVENT) cmake_pop_check_state() -check_function_exists(getopt_long HAVE_GETOPT_LONG) -# -# 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 +# Make sure we have vsnprintf() and snprintf(); we require them. # -# 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? +check_function_exists(vsnprintf HAVE_VSNPRINTF) +if(NOT HAVE_VSNPRINTF) + message(FATAL_ERROR "vsnprintf() is required but wasn't found") +endif(NOT HAVE_VSNPRINTF) +check_function_exists(snprintf HAVE_SNPRINTF) +if(NOT HAVE_SNPRINTF) + message(FATAL_ERROR "snprintf() is required but wasn't found") +endif() + +check_function_exists(getopt_long HAVE_GETOPT_LONG) +check_function_exists(strftime HAVE_STRFTIME) +check_function_exists(setlinebuf HAVE_SETLINEBUF) # -# We also don't need to waste time checking for fork() or vfork(). +# For Windows, 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) # # Some platforms may need -lnsl for getrpcbynumber. @@ -1116,11 +1107,6 @@ 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 WIN32) - if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF) - set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/snprintf.c) - endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF) -endif(NOT WIN32) add_library(netdissect STATIC ${NETDISSECT_SOURCE_LIST_C} diff --git a/addrtoname.c b/addrtoname.c index 1ba7e506..aa43be76 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -628,7 +628,7 @@ etheraddr_string(netdissect_options *ndo, const uint8_t *ep) } if (!ndo->ndo_nflag) { - nd_snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)", + snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)", tok2str(oui_values, "Unknown", oui)); } else *cp = '\0'; @@ -749,7 +749,7 @@ tcpport_string(netdissect_options *ndo, u_short port) tp->addr = i; tp->nxt = newhnamemem(ndo); - (void)nd_snprintf(buf, sizeof(buf), "%u", i); + (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, @@ -771,7 +771,7 @@ udpport_string(netdissect_options *ndo, u_short port) tp->addr = i; tp->nxt = newhnamemem(ndo); - (void)nd_snprintf(buf, sizeof(buf), "%u", i); + (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, @@ -829,7 +829,7 @@ init_servarray(netdissect_options *ndo) while (table->name) table = table->nxt; if (ndo->ndo_nflag) { - (void)nd_snprintf(buf, sizeof(buf), "%d", port); + (void)snprintf(buf, sizeof(buf), "%d", port); table->name = strdup(buf); } else table->name = strdup(sv->s_name); @@ -1333,7 +1333,7 @@ const char * ieee8021q_tci_string(const uint16_t tci) { static char buf[128]; - nd_snprintf(buf, sizeof(buf), "vlan %u, p %u%s", + snprintf(buf, sizeof(buf), "vlan %u, p %u%s", tci & 0xfff, tci >> 13, (tci & 0x1000) ? ", DEI" : ""); diff --git a/addrtostr.c b/addrtostr.c index 3b573529..62cc298a 100644 --- a/addrtostr.c +++ b/addrtostr.c @@ -191,7 +191,7 @@ addrtostr6 (const void *src, char *dst, size_t size) space_left -= added_space; break; } - snprintfed = nd_snprintf (dp, space_left, "%x", words[i]); + snprintfed = snprintf (dp, space_left, "%x", words[i]); if (snprintfed < 0) return (NULL); if ((size_t) snprintfed >= space_left) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 9e2c0268..5c753284 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -186,9 +186,6 @@ /* Define to 1 if you have the `setlinebuf' function. */ #cmakedefine HAVE_SETLINEBUF 1 -/* Define to 1 if you have the `snprintf' function. */ -#cmakedefine HAVE_SNPRINTF 1 - /* Define to 1 if you have the <stdint.h> header file. */ #cmakedefine HAVE_STDINT_H 1 @@ -237,9 +234,6 @@ /* Define to 1 if you have the `vfork' function. */ #cmakedefine HAVE_VFORK 1 -/* Define to 1 if you have the `vsnprintf' function. */ -#cmakedefine HAVE_VSNPRINTF 1 - /* Define to 1 if you have the `wsockinit' function. */ #cmakedefine HAVE_WSOCKINIT 1 diff --git a/config.h.in b/config.h.in index f032227a..e40e1089 100644 --- a/config.h.in +++ b/config.h.in @@ -183,9 +183,6 @@ /* Define to 1 if you have the `setlinebuf' function. */ #undef HAVE_SETLINEBUF -/* Define to 1 if you have the `snprintf' function. */ -#undef HAVE_SNPRINTF - /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H @@ -234,9 +231,6 @@ /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - /* define if libpcap has yydebug */ #undef HAVE_YYDEBUG @@ -676,7 +676,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -757,7 +756,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1010,15 +1008,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1156,7 +1145,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1309,7 +1298,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -5171,30 +5159,24 @@ fi done -needsnprintf=no -for ac_func in vsnprintf snprintf -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF +# +# Make sure we have vsnprintf() and snprintf(); we require them. +# +ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" +if test "x$ac_cv_func_vsnprintf" = xyes; then : else - needsnprintf=yes + as_fn_error $? "vsnprintf() is required but wasn't found" "$LINENO" 5 fi -done -if test $needsnprintf = yes; then - case " $LIBOBJS " in - *" snprintf.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" - ;; -esac +ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" +if test "x$ac_cv_func_snprintf" = xyes; then : +else + as_fn_error $? "snprintf() is required but wasn't found" "$LINENO" 5 fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5 $as_echo_n "checking for main in -lrpc... " >&6; } if ${ac_cv_lib_rpc_main+:} false; then : diff --git a/configure.ac b/configure.ac index cef1d6b7..ed3e14e3 100644 --- a/configure.ac +++ b/configure.ac @@ -428,12 +428,13 @@ AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long) AC_CHECK_FUNCS(fork vfork strftime) AC_CHECK_FUNCS(setlinebuf) -needsnprintf=no -AC_CHECK_FUNCS(vsnprintf snprintf,, - [needsnprintf=yes]) -if test $needsnprintf = yes; then - AC_LIBOBJ(snprintf) -fi +# +# Make sure we have vsnprintf() and snprintf(); we require them. +# +AC_CHECK_FUNC(vsnprintf,, + AC_MSG_ERROR([vsnprintf() is required but wasn't found])) +AC_CHECK_FUNC(snprintf,, + AC_MSG_ERROR([snprintf() is required but wasn't found])) AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc diff --git a/funcattrs.h b/funcattrs.h index 7fdbf925..8ac08c44 100644 --- a/funcattrs.h +++ b/funcattrs.h @@ -138,13 +138,9 @@ /* * For flagging arguments as format strings in MSVC. */ -#if _MSC_VER >= 1400 +#ifdef _MSC_VER #include <sal.h> - #if _MSC_VER > 1400 - #define FORMAT_STRING(p) _Printf_format_string_ p - #else - #define FORMAT_STRING(p) __format_string p - #endif + #define FORMAT_STRING(p) _Printf_format_string_ p #else #define FORMAT_STRING(p) p #endif diff --git a/missing/getservent.c b/missing/getservent.c index 198644f2..39cee068 100644 --- a/missing/getservent.c +++ b/missing/getservent.c @@ -65,9 +65,9 @@ const char *etc_path(const char *file) return (file); else #ifdef _WIN32 - nd_snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file); + snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file); #else - nd_snprintf(path, sizeof(path), "%s%s", env, file); + snprintf(path, sizeof(path), "%s%s", env, file); #endif return (path); } diff --git a/missing/snprintf.c b/missing/snprintf.c index 3b21f31f..2f12cf16 100644 --- a/missing/snprintf.c +++ b/missing/snprintf.c @@ -67,25 +67,6 @@ struct state { /* XXX - methods */ }; -#ifndef HAVE_VSNPRINTF -static int -sn_reserve (struct state *state, size_t n) -{ - return state->s + n > state->theend; -} - -static int -sn_append_char (struct state *state, unsigned char c) -{ - if (sn_reserve (state, 1)) { - return 1; - } else { - *state->s++ = c; - return 0; - } -} -#endif - #if 0 static int as_reserve (struct state *state, size_t n) @@ -454,37 +435,6 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) return 0; } -#ifndef HAVE_SNPRINTF -int -nd_snprintf (char *str, size_t sz, const char *format, ...) -{ - va_list args; - int ret; - - va_start(args, format); - ret = nd_vsnprintf (str, sz, format, args); - -#ifdef PARANOIA - { - int ret2; - char *tmp; - - tmp = malloc (sz); - if (tmp == NULL) - abort (); - - ret2 = vsprintf (tmp, format, args); - if (ret != ret2 || strcmp(str, tmp)) - abort (); - free (tmp); - } -#endif - - va_end(args); - return ret; -} -#endif - #if 0 #ifndef HAVE_ASPRINTF int @@ -516,45 +466,6 @@ asprintf (char **ret, const char *format, ...) } #endif -#ifndef HAVE_ASNPRINTF -int -nd_asnprintf (char **ret, size_t max_sz, const char *format, ...) -{ - va_list args; - int val; - - va_start(args, format); - val = nd_vasnprintf (ret, max_sz, format, args); - -#ifdef PARANOIA - { - int ret2; - char *tmp; - tmp = malloc (val + 1); - if (tmp == NULL) - abort (); - - ret2 = vsprintf (tmp, format, args); - if (val != ret2 || strcmp(*ret, tmp)) - abort (); - free (tmp); - } -#endif - - va_end(args); - return val; -} -#endif - -#ifndef HAVE_VASPRINTF -int -vasprintf (char **ret, const char *format, va_list args) -{ - return nd_vasnprintf (ret, 0, format, args); -} -#endif - - #ifndef HAVE_VASNPRINTF int nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) @@ -597,29 +508,3 @@ nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) } #endif #endif - -#ifndef HAVE_VSNPRINTF -int -nd_vsnprintf (char *str, size_t sz, const char *format, va_list args) -{ - struct state state; - int ret; - unsigned char *ustr = (unsigned char *)str; - - state.max_sz = 0; - state.sz = sz; - state.str = ustr; - state.s = ustr; - state.theend = ustr + sz - 1; - state.append_char = sn_append_char; - state.reserve = sn_reserve; - - ret = xyzprintf (&state, format, args); - *state.s = '\0'; - if (ret) - return sz; - else - return state.s - state.str; -} -#endif - diff --git a/missing/win_ether_ntohost.c b/missing/win_ether_ntohost.c index 6ac26b7c..05930923 100644 --- a/missing/win_ether_ntohost.c +++ b/missing/win_ether_ntohost.c @@ -85,9 +85,9 @@ const char *etc_path (const char *file) return (file); if (win9x) - nd_snprintf (path, sizeof(path), "%s\\etc\\%s", env, file); + snprintf (path, sizeof(path), "%s\\etc\\%s", env, file); else - nd_snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file); + snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file); return (path); } diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h index c52e72a9..aed38b31 100644 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -180,12 +180,9 @@ #define strtoint64_t strtoll /* - * Microsoft's documentation doesn't speak of LL as a valid - * suffix for 64-bit integers, so we'll just use i64. - * - * XXX - is that still the case as of VS 2015? + * And we have LL as a suffix for constants, so use that. */ - #define INT64_T_CONSTANT(constant) (constant##i64) + #define INT64_T_CONSTANT(constant) (constant##LL) #else /* * Non-Microsoft compiler. @@ -296,62 +293,6 @@ typedef char* caddr_t; #include "funcattrs.h" /* - * On Windows, snprintf(), with that name and with C99 behavior - i.e., - * guaranteeing that the formatted string is null-terminated - didn't - * appear until Visual Studio 2015. Prior to that, the C runtime had - * only _snprintf(), which *doesn't* guarantee that the string is - * null-terminated if it is truncated due to the buffer being too - * small. We therefore can't just define snprintf to be _snprintf - * and define vsnprintf to be _vsnprintf, as we're relying on null- - * termination of strings in all cases. - * - * 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. - * - * We assume all UN*Xes that have snprintf() and vsnprintf() provide - * C99 behavior. - */ -#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, ...) \ - _snprintf_s(buf, buflen, _TRUNCATE, __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. */ #if defined(_WIN32) || defined(MSDOS) diff --git a/netdissect.c b/netdissect.c index 4d4a4a59..7e46d6aa 100644 --- a/netdissect.c +++ b/netdissect.c @@ -123,14 +123,14 @@ nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size) { #ifdef USE_LIBSMI if (smiLoadModule(module) == 0) { - nd_snprintf(errbuf, errbuf_size, "could not load MIB module %s", + snprintf(errbuf, errbuf_size, "could not load MIB module %s", module); return (-1); } nd_smi_module_loaded = 1; return (0); #else - nd_snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support", + snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support", module); return (-1); #endif diff --git a/netdissect.h b/netdissect.h index c3621ffa..66ae4fad 100644 --- a/netdissect.h +++ b/netdissect.h @@ -112,8 +112,6 @@ typedef unsigned char nd_byte; #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) #endif -/* nd_snprintf et al */ - #include <stdarg.h> #include <pcap.h> diff --git a/parsenfsfh.c b/parsenfsfh.c index fa3e545a..b3f54900 100644 --- a/parsenfsfh.c +++ b/parsenfsfh.c @@ -400,7 +400,7 @@ Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len, #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)nd_snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", + (void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", GET_U_1(fhp + i)); fsidp->Opaque_Handle[i*2] = '\0'; diff --git a/print-ascii.c b/print-ascii.c index 63f15f0f..56efc84a 100644 --- a/print-ascii.c +++ b/print-ascii.c @@ -117,7 +117,7 @@ hex_and_ascii_print_with_offset(netdissect_options *ndo, const char *ident, cp++; s2 = GET_U_1(cp); cp++; - (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), + (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x%02x", s1, s2); hsp += HEXDUMP_HEXSTUFF_PER_SHORT; *(asp++) = (char)(ND_ISGRAPH(s1) ? s1 : '.'); @@ -136,7 +136,7 @@ hex_and_ascii_print_with_offset(netdissect_options *ndo, const char *ident, if (length & 1) { s1 = GET_U_1(cp); cp++; - (void)nd_snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), + (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x", s1); hsp += 3; *(asp++) = (char)(ND_ISGRAPH(s1) ? s1 : '.'); diff --git a/print-atalk.c b/print-atalk.c index 99cd850e..57bd140f 100644 --- a/print-atalk.c +++ b/print-atalk.c @@ -655,7 +655,7 @@ ataddr_string(netdissect_options *ndo, if (tp2->addr == i) { tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(ndo); - (void)nd_snprintf(nambuf, sizeof(nambuf), "%s.%u", + (void)snprintf(nambuf, sizeof(nambuf), "%s.%u", tp2->name, athost); tp->name = strdup(nambuf); if (tp->name == NULL) @@ -667,9 +667,9 @@ ataddr_string(netdissect_options *ndo, tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(ndo); if (athost != 255) - (void)nd_snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost); + (void)snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost); else - (void)nd_snprintf(nambuf, sizeof(nambuf), "%u", atnet); + (void)snprintf(nambuf, sizeof(nambuf), "%u", atnet); tp->name = strdup(nambuf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, @@ -693,7 +693,7 @@ ddpskt_string(netdissect_options *ndo, static char buf[8]; if (ndo->ndo_nflag) { - (void)nd_snprintf(buf, sizeof(buf), "%u", skt); + (void)snprintf(buf, sizeof(buf), "%u", skt); return (buf); } return (tok2str(skt2str, "%u", skt)); diff --git a/print-babel.c b/print-babel.c index f01fbc33..5f1d90f0 100644 --- a/print-babel.c +++ b/print-babel.c @@ -111,7 +111,7 @@ static const char * format_id(netdissect_options *ndo, const u_char *id) { static char buf[25]; - nd_snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", GET_U_1(id), GET_U_1(id + 1), GET_U_1(id + 2), GET_U_1(id + 3), GET_U_1(id + 4), GET_U_1(id + 5), GET_U_1(id + 6), GET_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) - nd_snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96); + snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96); else - nd_snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen); + 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)"; - nd_snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100); + 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")]; - nd_snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000); + snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000); return buf; } diff --git a/print-bgp.c b/print-bgp.c index 572f1ff5..301d24f8 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -526,9 +526,9 @@ as_printf(netdissect_options *ndo, char *str, size_t size, u_int asnum) { if (!ndo->ndo_bflag || asnum <= 0xFFFF) { - nd_snprintf(str, size, "%u", asnum); + snprintf(str, size, "%u", asnum); } else { - nd_snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF); + snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF); } return str; } @@ -557,7 +557,7 @@ decode_prefix4(netdissect_options *ndo, if (plen % 8) { ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - nd_snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, (const u_char *)&addr), plen); + snprintf(buf, buflen, "%s/%u", ipaddr_string(ndo, (const u_char *)&addr), plen); return 1 + plenbytes; trunc: @@ -606,7 +606,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 */ - nd_snprintf(buf, buflen, "%s/%u, label:%u %s", + snprintf(buf, buflen, "%s/%u, label:%u %s", ipaddr_string(ndo, (const u_char *)&addr), plen, GET_BE_U_3(pptr + 1)>>4, @@ -638,14 +638,14 @@ bgp_vpn_ip_print(netdissect_options *ndo, switch(addr_length) { case (sizeof(nd_ipv4) << 3): /* 32 */ ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); - nd_snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr)); + snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr)); break; case (sizeof(nd_ipv6) << 3): /* 128 */ ND_TCHECK_LEN(pptr, sizeof(nd_ipv6)); - nd_snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr)); + snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr)); break; default: - nd_snprintf(pos, sizeof(addr), "bogus address length %u", addr_length); + snprintf(pos, sizeof(addr), "bogus address length %u", addr_length); break; } pos += strlen(pos); @@ -692,7 +692,7 @@ bgp_vpn_sg_print(netdissect_options *ndo, total_length += (addr_length >> 3) + 1; offset = (u_int)strlen(buf); if (addr_length) { - nd_snprintf(buf + offset, buflen - offset, ", Source %s", + snprintf(buf + offset, buflen - offset, ", Source %s", bgp_vpn_ip_print(ndo, pptr, addr_length)); pptr += (addr_length >> 3); } @@ -707,7 +707,7 @@ bgp_vpn_sg_print(netdissect_options *ndo, total_length += (addr_length >> 3) + 1; offset = (u_int)strlen(buf); if (addr_length) { - nd_snprintf(buf + offset, buflen - offset, ", Group %s", + snprintf(buf + offset, buflen - offset, ", Group %s", bgp_vpn_ip_print(ndo, pptr, addr_length)); pptr += (addr_length >> 3); } @@ -730,7 +730,7 @@ bgp_vpn_rd_print(netdissect_options *ndo, case 0: /* 2-byte-AS:number fmt */ - nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)", + snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)", GET_BE_U_2(pptr + 2), GET_BE_U_4(pptr + 4), GET_U_1(pptr + 4), GET_U_1(pptr + 5), @@ -739,7 +739,7 @@ bgp_vpn_rd_print(netdissect_options *ndo, case 1: /* IP-address:AS fmt */ - nd_snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u", + snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u", GET_U_1(pptr + 2), GET_U_1(pptr + 3), GET_U_1(pptr + 4), GET_U_1(pptr + 5), GET_BE_U_2(pptr + 6)); @@ -747,14 +747,14 @@ bgp_vpn_rd_print(netdissect_options *ndo, case 2: /* 4-byte-AS:number fmt */ - nd_snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)", + snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)", as_printf(ndo, astostr, sizeof(astostr), GET_BE_U_4(pptr + 2)), GET_BE_U_2(pptr + 6), GET_U_1(pptr + 2), GET_U_1(pptr + 3), GET_U_1(pptr + 4), GET_U_1(pptr + 5), GET_BE_U_2(pptr + 6)); break; default: - nd_snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format"); + snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format"); break; } pos += strlen(pos); @@ -928,7 +928,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 */ - nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s", + snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s", bgp_vpn_rd_print(ndo, pptr+4), ipaddr_string(ndo, (const u_char *)&addr), plen, @@ -980,7 +980,7 @@ decode_mdt_vpn_nlri(netdissect_options *ndo, /* MDT Group Address */ ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); - nd_snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s", + 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; @@ -1022,7 +1022,7 @@ decode_multicast_vpn(netdissect_options *ndo, route_length = GET_U_1(pptr); pptr++; - nd_snprintf(buf, buflen, "Route-Type: %s (%u), length: %u", + snprintf(buf, buflen, "Route-Type: %s (%u), length: %u", tok2str(bgp_multicast_vpn_route_type_values, "Unknown", route_type), route_type, route_length); @@ -1031,7 +1031,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 = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s", + 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)); @@ -1039,7 +1039,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 = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", + snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", bgp_vpn_rd_print(ndo, pptr), as_printf(ndo, astostr, sizeof(astostr), GET_BE_U_4(pptr + BGP_VPN_RD_LEN))); @@ -1048,7 +1048,7 @@ decode_multicast_vpn(netdissect_options *ndo, case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI: ND_TCHECK_LEN(pptr, BGP_VPN_RD_LEN); offset = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", RD: %s", + snprintf(buf + offset, buflen - offset, ", RD: %s", bgp_vpn_rd_print(ndo, pptr)); pptr += BGP_VPN_RD_LEN; @@ -1057,14 +1057,14 @@ decode_multicast_vpn(netdissect_options *ndo, ND_TCHECK_LEN(pptr, addr_length); offset = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", Originator %s", + 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 = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", RD: %s", + snprintf(buf + offset, buflen - offset, ", RD: %s", bgp_vpn_rd_print(ndo, pptr)); pptr += BGP_VPN_RD_LEN; @@ -1075,7 +1075,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 = (u_int)strlen(buf); - nd_snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", + snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", bgp_vpn_rd_print(ndo, pptr), as_printf(ndo, astostr, sizeof(astostr), GET_BE_U_4(pptr + BGP_VPN_RD_LEN))); @@ -1137,7 +1137,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo, /* assume AD-only with RD, BGPNH */ ND_TCHECK_LEN(pptr, 12); buf[0] = '\0'; - stringlen = nd_snprintf(buf, buflen, "RD: %s, BGPNH: %s", + stringlen = snprintf(buf, buflen, "RD: %s, BGPNH: %s", bgp_vpn_rd_print(ndo, pptr), ipaddr_string(ndo, pptr+8)); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); @@ -1150,7 +1150,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo, ND_TCHECK_LEN(pptr, 15); buf[0] = '\0'; - stringlen = nd_snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u", + stringlen = snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u", bgp_vpn_rd_print(ndo, pptr), GET_BE_U_2(pptr + 8), GET_BE_U_2(pptr + 10), @@ -1163,7 +1163,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo, while (tlen != 0) { if (tlen < 3) { if (buflen != 0) { - stringlen=nd_snprintf(buf,buflen, "\n\t\tran past the end"); + stringlen=snprintf(buf,buflen, "\n\t\tran past the end"); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } return plen + 2; @@ -1178,7 +1178,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo, switch(tlv_type) { case 1: if (buflen != 0) { - stringlen=nd_snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x", + stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x", tlv_type, tlv_len); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); @@ -1186,14 +1186,14 @@ decode_labeled_vpn_l2(netdissect_options *ndo, while (ttlv_len != 0) { if (tlen < 1) { if (buflen != 0) { - stringlen=nd_snprintf(buf,buflen, " (ran past the end)"); + stringlen=snprintf(buf,buflen, " (ran past the end)"); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } return plen + 2; } ND_TCHECK_1(pptr); if (buflen != 0) { - stringlen=nd_snprintf(buf,buflen, "%02x", + stringlen=snprintf(buf,buflen, "%02x", GET_U_1(pptr)); pptr++; UPDATE_BUF_BUFLEN(buf, buflen, stringlen); @@ -1204,14 +1204,14 @@ decode_labeled_vpn_l2(netdissect_options *ndo, break; default: if (buflen != 0) { - stringlen=nd_snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u", + stringlen=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=nd_snprintf(buf,buflen, " (ran past the end)"); + stringlen=snprintf(buf,buflen, " (ran past the end)"); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } return plen + 2; @@ -1254,7 +1254,7 @@ decode_prefix6(netdissect_options *ndo, addr[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - nd_snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, (const u_char *)&addr), plen); + snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, (const u_char *)&addr), plen); return 1 + plenbytes; trunc: @@ -1294,7 +1294,7 @@ decode_labeled_prefix6(netdissect_options *ndo, ((0xff00 >> (plen % 8)) & 0xff); } /* the label may get offsetted by 4 bits so lets shift it right */ - nd_snprintf(buf, buflen, "%s/%u, label:%u %s", + snprintf(buf, buflen, "%s/%u, label:%u %s", ip6addr_string(ndo, (const u_char *)&addr), plen, GET_BE_U_3(pptr + 1)>>4, @@ -1335,7 +1335,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 */ - nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s", + snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s", bgp_vpn_rd_print(ndo, pptr+4), ip6addr_string(ndo, (const u_char *)&addr), plen, @@ -1368,7 +1368,7 @@ decode_clnp_prefix(netdissect_options *ndo, addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - nd_snprintf(buf, buflen, "%s/%u", + snprintf(buf, buflen, "%s/%u", isonsap_string(ndo, addr,(plen + 7) / 8), plen); @@ -1403,7 +1403,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 */ - nd_snprintf(buf, buflen, "RD: %s, %s/%u, label:%u %s", + 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, diff --git a/print-cnfp.c b/print-cnfp.c index 0ce51144..1e4e1ae1 100644 --- a/print-cnfp.c +++ b/print-cnfp.c @@ -301,16 +301,16 @@ cnfp_v5_print(netdissect_options *ndo, const u_char *cp) GET_BE_U_4(nr->last_time)%1000); asbuf[0] = buf[0] = '\0'; - nd_snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->src_mask)); - nd_snprintf(asbuf, sizeof(asbuf), ":%u", + snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->src_mask)); + snprintf(asbuf, sizeof(asbuf), ":%u", GET_BE_U_2(nr->src_as)); ND_PRINT("\n %s%s%s:%u ", intoa(GET_IPV4_TO_NETWORK_ORDER(nr->src_ina)), buf, asbuf, GET_BE_U_2(nr->srcport)); - nd_snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->dst_mask)); - nd_snprintf(asbuf, sizeof(asbuf), ":%u", + snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->dst_mask)); + snprintf(asbuf, sizeof(asbuf), ":%u", GET_BE_U_2(nr->dst_as)); ND_PRINT("> %s%s%s:%u ", intoa(GET_IPV4_TO_NETWORK_ORDER(nr->dst_ina)), @@ -404,16 +404,16 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp) GET_BE_U_4(nr->last_time)%1000); asbuf[0] = buf[0] = '\0'; - nd_snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->src_mask)); - nd_snprintf(asbuf, sizeof(asbuf), ":%u", + snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->src_mask)); + snprintf(asbuf, sizeof(asbuf), ":%u", GET_BE_U_2(nr->src_as)); ND_PRINT("\n %s%s%s:%u ", intoa(GET_IPV4_TO_NETWORK_ORDER(nr->src_ina)), buf, asbuf, GET_BE_U_2(nr->srcport)); - nd_snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->dst_mask)); - nd_snprintf(asbuf, sizeof(asbuf), ":%u", + snprintf(buf, sizeof(buf), "/%u", GET_U_1(nr->dst_mask)); + snprintf(asbuf, sizeof(asbuf), ":%u", GET_BE_U_2(nr->dst_as)); ND_PRINT("> %s%s%s:%u ", intoa(GET_IPV4_TO_NETWORK_ORDER(nr->dst_ina)), @@ -444,7 +444,7 @@ cnfp_v6_print(netdissect_options *ndo, const u_char *cp) } buf[0]='\0'; - nd_snprintf(buf, sizeof(buf), "(%u<>%u encaps)", + snprintf(buf, sizeof(buf), "(%u<>%u encaps)", (GET_BE_U_2(nr->flags) >> 8) & 0xff, (GET_BE_U_2(nr->flags)) & 0xff); ND_PRINT("tos %u, %u (%u octets) %s", diff --git a/print-decnet.c b/print-decnet.c index e595067b..31166e3f 100644 --- a/print-decnet.c +++ b/print-decnet.c @@ -1245,7 +1245,7 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr) str = (char *)malloc(siz = sizeof("00.0000")); if (str == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "dnnum_string: malloc"); - nd_snprintf(str, siz, "%u.%u", area, node); + snprintf(str, siz, "%u.%u", area, node); return(str); } @@ -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){ - nd_snprintf(buffer, sizeof(buffer), "DLCI %u", dlci); + snprintf(buffer, sizeof(buffer), "DLCI %u", dlci); } return buffer; diff --git a/print-hncp.c b/print-hncp.c index 60a7ca9b..0593b65b 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -162,7 +162,7 @@ format_nid(netdissect_options *ndo, const u_char *data) static char buf[4][sizeof("01:01:01:01")]; static int i = 0; i = (i + 1) % 4; - nd_snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x", + snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x", GET_U_1(data), GET_U_1(data + 1), GET_U_1(data + 2), GET_U_1(data + 3)); return buf[i]; @@ -174,7 +174,7 @@ format_256(netdissect_options *ndo, const u_char *data) static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")]; static int i = 0; i = (i + 1) % 4; - nd_snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, + snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, GET_BE_U_8(data), GET_BE_U_8(data + 8), GET_BE_U_8(data + 16), @@ -189,7 +189,7 @@ format_interval(const uint32_t n) static char buf[4][sizeof("0000000.000s")]; static int i = 0; i = (i + 1) % 4; - nd_snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000); + snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000); return buf[i]; } @@ -227,7 +227,7 @@ print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length) ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - nd_snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, (const u_char *)&addr), plen); + snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, (const u_char *)&addr), plen); plenbytes += 1 + IPV4_MAPPED_HEADING_LEN; } else { plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf)); diff --git a/print-icmp.c b/print-icmp.c index c83c809d..8d7c3636 100644 --- a/print-icmp.c +++ b/print-icmp.c @@ -286,7 +286,7 @@ icmp_tstamp_print(u_int tstamp) sec = tstamp / 1000; min = sec / 60; sec -= min * 60; hrs = min / 60; min -= hrs * 60; - nd_snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec); + snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec); return buf; } @@ -326,7 +326,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)nd_snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u", + (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u", icmp_type == ICMP_ECHO ? "request" : "reply", GET_BE_U_2(dp->icmp_id), @@ -338,20 +338,20 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * switch (icmp_code) { case ICMP_UNREACH_NET: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "net %s unreachable", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_HOST: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_PROTOCOL: ND_TCHECK_1(dp->icmp_ip.ip_p); - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s protocol %u unreachable", ipaddr_string(ndo, dp->icmp_ip.ip_dst), GET_U_1(dp->icmp_ip.ip_p)); @@ -368,21 +368,21 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * switch (ip_proto) { case IPPROTO_TCP: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s tcp port %s unreachable", ipaddr_string(ndo, oip->ip_dst), tcpport_string(ndo, dport)); break; case IPPROTO_UDP: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s udp port %s unreachable", ipaddr_string(ndo, oip->ip_dst), udpport_string(ndo, dport)); break; default: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s protocol %u port %u unreachable", ipaddr_string(ndo, oip->ip_dst), ip_proto, dport); @@ -396,11 +396,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 = GET_BE_U_2(mp->nexthopmtu); if (mtu) { - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag (mtu %u)", ipaddr_string(ndo, dp->icmp_ip.ip_dst), mtu); } else { - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); } @@ -408,73 +408,73 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * break; case ICMP_UNREACH_SRCFAIL: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s unreachable - source route failed", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_NET_UNKNOWN: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "net %s unreachable - unknown", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_HOST_UNKNOWN: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - unknown", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_ISOLATED: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s unreachable - source host isolated", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_NET_PROHIB: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "net %s unreachable - admin prohibited", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_HOST_PROHIB: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - admin prohibited", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_TOSNET: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "net %s unreachable - tos prohibited", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_TOSHOST: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - tos prohibited", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_FILTER_PROHIB: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - admin prohibited filter", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_HOST_PRECEDENCE: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - host precedence violation", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; case ICMP_UNREACH_PRECEDENCE_CUTOFF: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "host %s unreachable - precedence cutoff", ipaddr_string(ndo, dp->icmp_ip.ip_dst)); break; default: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "%s unreachable - #%u", ipaddr_string(ndo, dp->icmp_ip.ip_dst), icmp_code); @@ -487,35 +487,35 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * switch (icmp_code) { case ICMP_REDIRECT_NET: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "redirect %s to net %s", ipaddr_string(ndo, dp->icmp_ip.ip_dst), ipaddr_string(ndo, dp->icmp_gwaddr)); break; case ICMP_REDIRECT_HOST: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "redirect %s to host %s", ipaddr_string(ndo, dp->icmp_ip.ip_dst), ipaddr_string(ndo, dp->icmp_gwaddr)); break; case ICMP_REDIRECT_TOSNET: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "redirect-tos %s to net %s", ipaddr_string(ndo, dp->icmp_ip.ip_dst), ipaddr_string(ndo, dp->icmp_gwaddr)); break; case ICMP_REDIRECT_TOSHOST: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "redirect-tos %s to host %s", ipaddr_string(ndo, dp->icmp_ip.ip_dst), ipaddr_string(ndo, dp->icmp_gwaddr)); break; default: - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "redirect-#%u %s to %s", icmp_code, ipaddr_string(ndo, dp->icmp_ip.ip_dst), ipaddr_string(ndo, dp->icmp_gwaddr)); @@ -529,7 +529,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)nd_snprintf(buf, sizeof(buf), "router advertisement"); + (void)snprintf(buf, sizeof(buf), "router advertisement"); cp = buf + strlen(buf); ihp = (const struct ih_rdiscovery *)&dp->icmp_void; @@ -538,13 +538,13 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * cp = buf + strlen(buf); lifetime = GET_BE_U_2(ihp->ird_lifetime); if (lifetime < 60) { - (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u", + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", lifetime); } else if (lifetime < 60 * 60) { - (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", lifetime / 60, lifetime % 60); } else { - (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u:%02u", lifetime / 3600, (lifetime % 3600) / 60, @@ -553,19 +553,19 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * cp = buf + strlen(buf); num = GET_U_1(ihp->ird_addrnum); - (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num); + (void)snprintf(cp, sizeof(buf) - (cp - buf), " %u:", num); cp = buf + strlen(buf); size = GET_U_1(ihp->ird_addrsiz); if (size != 2) { - (void)nd_snprintf(cp, sizeof(buf) - (cp - buf), + (void)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)nd_snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", + (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", ipaddr_string(ndo, idp->ird_addr), GET_BE_U_4(idp->ird_pref)); cp = buf + strlen(buf); @@ -588,7 +588,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * break; default: - (void)nd_snprintf(buf, sizeof(buf), "time exceeded-#%u", + (void)snprintf(buf, sizeof(buf), "time exceeded-#%u", icmp_code); break; } @@ -596,11 +596,11 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * case ICMP_PARAMPROB: if (icmp_code) - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "parameter problem - code %u", icmp_code); else { ND_TCHECK_1(dp->icmp_pptr); - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "parameter problem - octet %u", GET_U_1(dp->icmp_pptr)); } @@ -608,13 +608,13 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * case ICMP_MASKREPLY: ND_TCHECK_4(dp->icmp_mask); - (void)nd_snprintf(buf, sizeof(buf), "address mask is 0x%08x", + (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", GET_BE_U_4(dp->icmp_mask)); break; case ICMP_TSTAMP: ND_TCHECK_2(dp->icmp_seq); - (void)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "time stamp query id %u seq %u", GET_BE_U_2(dp->icmp_id), GET_BE_U_2(dp->icmp_seq)); @@ -622,15 +622,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)nd_snprintf(buf, sizeof(buf), + (void)snprintf(buf, sizeof(buf), "time stamp reply id %u seq %u: org %s", GET_BE_U_2(dp->icmp_id), GET_BE_U_2(dp->icmp_seq), icmp_tstamp_print(GET_BE_U_4(dp->icmp_otime))); - (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s", + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s", icmp_tstamp_print(GET_BE_U_4(dp->icmp_rtime))); - (void)nd_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s", + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s", icmp_tstamp_print(GET_BE_U_4(dp->icmp_ttime))); break; diff --git a/print-icmp6.c b/print-icmp6.c index 1f0c24ba..0178a355 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -758,7 +758,7 @@ get_lifetime(uint32_t v) if (v == (uint32_t)~0UL) return "infinity"; else { - nd_snprintf(buf, sizeof(buf), "%us", v); + snprintf(buf, sizeof(buf), "%us", v); return buf; } } diff --git a/print-ipx.c b/print-ipx.c index 4f4e3059..24d92096 100644 --- a/print-ipx.c +++ b/print-ipx.c @@ -106,7 +106,7 @@ ipxaddr_string(netdissect_options *ndo, uint32_t net, const u_char *node) { static char line[256]; - nd_snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x", + snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x", net, GET_U_1(node), GET_U_1(node + 1), GET_U_1(node + 2), GET_U_1(node + 3), GET_U_1(node + 4), GET_U_1(node + 5)); diff --git a/print-isakmp.c b/print-isakmp.c index 8c46bce4..b7b05116 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -2820,7 +2820,7 @@ static char * numstr(u_int x) { static char buf[20]; - nd_snprintf(buf, sizeof(buf), "#%u", x); + snprintf(buf, sizeof(buf), "#%u", x); return buf; } diff --git a/print-isoclns.c b/print-isoclns.c index 96a16bc3..6bbe75c3 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -1712,19 +1712,19 @@ isis_print_id(netdissect_options *ndo, const uint8_t *cp, u_int id_len) if (sysid_len > id_len) sysid_len = id_len; for (i = 1; i <= sysid_len; i++) { - nd_snprintf(pos, sizeof(id) - (pos - id), "%02x", GET_U_1(cp)); + snprintf(pos, sizeof(id) - (pos - id), "%02x", GET_U_1(cp)); cp++; pos += strlen(pos); if (i == 2 || i == 4) *pos++ = '.'; } if (id_len >= NODE_ID_LEN) { - nd_snprintf(pos, sizeof(id) - (pos - id), ".%02x", GET_U_1(cp)); + snprintf(pos, sizeof(id) - (pos - id), ".%02x", GET_U_1(cp)); cp++; pos += strlen(pos); } if (id_len == LSP_ID_LEN) - nd_snprintf(pos, sizeof(id) - (pos - id), "-%02x", GET_U_1(cp)); + snprintf(pos, sizeof(id) - (pos - id), "-%02x", GET_U_1(cp)); return (id); } @@ -1913,7 +1913,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (subtlv_sum_len) { ND_PRINT(" (%u)", subtlv_sum_len); /* prepend the indent string */ - nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); + snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); ident = ident_buffer; while (subtlv_sum_len != 0) { ND_TCHECK_2(tptr); @@ -2246,7 +2246,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo, subtlvlen=GET_U_1(tptr + 1); tptr+=2; /* prepend the indent string */ - nd_snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); + snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer)) return(0); tptr+=subtlvlen; diff --git a/print-lldp.c b/print-lldp.c index 9445f702..a578f4ea 100644 --- a/print-lldp.c +++ b/print-lldp.c @@ -1360,10 +1360,10 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len) } if (!pfunc) { - nd_snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !", + snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !", tok2str(af_values, "Unknown", af), af); } else { - nd_snprintf(buf, sizeof(buf), "AFI %s (%u): %s", + snprintf(buf, sizeof(buf), "AFI %s (%u): %s", tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1)); } diff --git a/print-nfs.c b/print-nfs.c index 76bbfd3e..e660a706 100644 --- a/print-nfs.c +++ b/print-nfs.c @@ -357,11 +357,11 @@ nfsreply_print(netdissect_options *ndo, ND_TCHECK_4(rp->rm_xid); if (!ndo->ndo_nflag) { strlcpy(srcid, "nfs", sizeof(srcid)); - nd_snprintf(dstid, sizeof(dstid), "%u", + snprintf(dstid, sizeof(dstid), "%u", GET_BE_U_4(rp->rm_xid)); } else { - nd_snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); - nd_snprintf(dstid, sizeof(dstid), "%u", + snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); + snprintf(dstid, sizeof(dstid), "%u", GET_BE_U_4(rp->rm_xid)); } print_nfsaddr(ndo, bp2, srcid, dstid); diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 048031aa..4cf766bc 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -700,7 +700,7 @@ vlan_str(const uint16_t vid) if (vid == OFP_VLAN_NONE) return "NONE"; - nd_snprintf(buf, sizeof(buf), "%u%s", vid, + snprintf(buf, sizeof(buf), "%u%s", vid, (vid > 0 && vid < 0x0fff) ? "" : " (bogus)"); return buf; } @@ -709,7 +709,7 @@ static const char * pcp_str(const uint8_t pcp) { static char buf[sizeof("255 (bogus)")]; - nd_snprintf(buf, sizeof(buf), "%u%s", pcp, + snprintf(buf, sizeof(buf), "%u%s", pcp, pcp <= 7 ? "" : " (bogus)"); return buf; } @@ -1186,7 +1186,7 @@ acl_print(netdissect_options *ndo, acl & PRSFS_ADMINISTER ? "a" : ""); for (i = 0; i < pos; i++) { - nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); + snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); if (sscanf((char *) s, fmt, user, &acl, &n) != 2) goto finish; s += n; @@ -1200,7 +1200,7 @@ acl_print(netdissect_options *ndo, } for (i = 0; i < neg; i++) { - nd_snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); + snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); if (sscanf((char *) s, fmt, user, &acl, &n) != 2) goto finish; s += n; diff --git a/print-snmp.c b/print-snmp.c index aa2974cc..6058294b 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -197,7 +197,7 @@ static const char *ErrorStatus[] = { #define DECODE_ErrorStatus(e) \ ( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \ ? ErrorStatus[e] \ - : (nd_snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf)) + : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf)) /* * generic-trap values in the SNMP Trap-PDU @@ -215,7 +215,7 @@ static const char *GenericTrap[] = { #define DECODE_GenericTrap(t) \ ( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \ ? GenericTrap[t] \ - : (nd_snprintf(buf, sizeof(buf), "gt=%d", t), buf)) + : (snprintf(buf, sizeof(buf), "gt=%d", t), buf)) /* * ASN.1 type class table diff --git a/print-stp.c b/print-stp.c index f87529f3..ce606d94 100644 --- a/print-stp.c +++ b/print-stp.c @@ -91,7 +91,7 @@ stp_print_bridge_id(netdissect_options *ndo, const u_char *p) { static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")]; - nd_snprintf(bridge_id_str, sizeof(bridge_id_str), + snprintf(bridge_id_str, sizeof(bridge_id_str), "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", GET_U_1(p), GET_U_1(p + 1), GET_U_1(p + 2), GET_U_1(p + 3), GET_U_1(p + 4), GET_U_1(p + 5), diff --git a/print-sunrpc.c b/print-sunrpc.c index 773e8b56..94b86707 100644 --- a/print-sunrpc.c +++ b/print-sunrpc.c @@ -172,13 +172,13 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp, ND_TCHECK_SIZE(rp); if (!ndo->ndo_nflag) { - nd_snprintf(srcid, sizeof(srcid), "0x%x", + snprintf(srcid, sizeof(srcid), "0x%x", GET_BE_U_4(rp->rm_xid)); strlcpy(dstid, "sunrpc", sizeof(dstid)); } else { - nd_snprintf(srcid, sizeof(srcid), "0x%x", + snprintf(srcid, sizeof(srcid), "0x%x", GET_BE_U_4(rp->rm_xid)); - nd_snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT); + snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT); } switch (IP_V((const struct ip *)bp2)) { @@ -240,7 +240,7 @@ progstr(uint32_t prog) rp = getrpcbynumber(prog); if (rp == NULL) #endif - (void) nd_snprintf(buf, sizeof(buf), "#%u", prog); + (void) snprintf(buf, sizeof(buf), "#%u", prog); #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H) else strlcpy(buf, rp->r_name, sizeof(buf)); diff --git a/print-telnet.c b/print-telnet.c index f2ff1389..8dd5f2d6 100644 --- a/print-telnet.c +++ b/print-telnet.c @@ -381,7 +381,7 @@ numstr(int x) { static char buf[20]; - nd_snprintf(buf, sizeof(buf), "%#x", x); + snprintf(buf, sizeof(buf), "%#x", x); return buf; } diff --git a/print-zephyr.c b/print-zephyr.c index d2fbf4d0..10aaf216 100644 --- a/print-zephyr.c +++ b/print-zephyr.c @@ -119,7 +119,7 @@ z_triple(const char *class, const char *inst, const char *recipient) { if (!*recipient) recipient = "*"; - nd_snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient); + snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient); z_buf[sizeof(z_buf)-1] = '\0'; return z_buf; } @@ -1074,17 +1074,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) { - nd_snprintf(ret, sizeof(ret), "%s - %s (%s)", + snprintf(ret, sizeof(ret), "%s - %s (%s)", err_classes[i].class, err[j].name, err[j].message); return ret; } } - nd_snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num); + snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num); return ret; } - nd_snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num); + snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num); return(ret); } @@ -1965,6 +1965,6 @@ nt_errstr(uint32_t err) return nt_errors[i].name; } - nd_snprintf(ret, sizeof(ret), "0x%08x", err); + snprintf(ret, sizeof(ret), "0x%08x", err); return ret; } @@ -844,7 +844,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 (nd_snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX) + if (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); @@ -1343,7 +1343,7 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf) /* * Return an error for our caller to handle. */ - nd_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)", + snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)", device, pcap_statustostr(status), cp); pcap_close(pc); return (NULL); @@ -1357,7 +1357,7 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf) char sysctl[32]; size_t s = sizeof(parent); - nd_snprintf(sysctl, sizeof(sysctl), + snprintf(sysctl, sizeof(sysctl), "net.wlan.%d.%%parent", atoi(device + 4)); sysctlbyname(sysctl, parent, &s, NULL, 0); strlcpy(newdev, device, sizeof(newdev)); diff --git a/util-print.c b/util-print.c index e896a2df..c60cc93b 100644 --- a/util-print.c +++ b/util-print.c @@ -507,7 +507,7 @@ tok2strbuf(const struct tok *lp, const char *fmt, if (fmt == NULL) fmt = "#%d"; - (void)nd_snprintf(buf, bufsize, fmt, v); + (void)snprintf(buf, bufsize, fmt, v); return (const char *)buf; } @@ -579,7 +579,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)nd_snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v); + (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v); return (buf); } @@ -621,7 +621,7 @@ tok2strary_internal(const char **lp, int n, const char *fmt, return lp[v]; if (fmt == NULL) fmt = "#%d"; - (void)nd_snprintf(buf, sizeof(buf), fmt, v); + (void)snprintf(buf, sizeof(buf), fmt, v); return (buf); } |