summaryrefslogtreecommitdiff
path: root/print-hncp.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 /print-hncp.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 'print-hncp.c')
-rw-r--r--print-hncp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/print-hncp.c b/print-hncp.c
index 0dee297f..1121d2a1 100644
--- a/print-hncp.c
+++ b/print-hncp.c
@@ -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));