summaryrefslogtreecommitdiff
path: root/addrtoname.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-01-29 15:48:55 -0800
committerGuy Harris <guy@alum.mit.edu>2018-01-29 15:48:55 -0800
commitc499612a7f1024a183d0200ef5f1ea7fba63a3e4 (patch)
tree5ffc65612e07d03e445e58a02d9e349c13eb0af7 /addrtoname.c
parent1e120597d2cb5864d52ca99ca6e167f2454c3153 (diff)
downloadtcpdump-c499612a7f1024a183d0200ef5f1ea7fba63a3e4.tar.gz
Add nd_{v}snprintf() routines/wrappers.
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).
Diffstat (limited to 'addrtoname.c')
-rw-r--r--addrtoname.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/addrtoname.c b/addrtoname.c
index ac79c0f2..effc0914 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -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" : "");