From: Guy Harris Date: Wed, 4 Nov 2015 01:18:38 +0000 (-0800) Subject: Oops, forgot to add the file with the Windows _snprintf() wrappers. X-Git-Tag: libpcap-1.8.0-bp~118 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/e5b5d5bcaf5e09d1fa55ecfa481532475c29db5e?ds=sidebyside Oops, forgot to add the file with the Windows _snprintf() wrappers. --- diff --git a/missing/win_snprintf.c b/missing/win_snprintf.c new file mode 100644 index 00000000..6e74d859 --- /dev/null +++ b/missing/win_snprintf.c @@ -0,0 +1,31 @@ +#include +#include + +int +pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args) +{ + int ret; + + ret = _vsnprintf(str, str_size, 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 +pcap_snprintf(char *str, size_t str_size, const char *format, ...) +{ + va_list args; + int ret; + + va_start(args, format); + ret = pcap_vsnprintf(str, str_size, format, args); + va_end(args); + return (ret); +}