summaryrefslogtreecommitdiff
path: root/missing/win_snprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/win_snprintf.c')
-rw-r--r--missing/win_snprintf.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/missing/win_snprintf.c b/missing/win_snprintf.c
index 65a8ea1a5cd9..f42240352920 100644
--- a/missing/win_snprintf.c
+++ b/missing/win_snprintf.c
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <stdarg.h>
+#include "portability.h"
+
int
pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
{
@@ -13,6 +15,16 @@ pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
* 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.
+ *
+ * We don't, however, offer C99 behavior for the return
+ * value; _vsnprintf_s() returns -1, not the number of
+ * characters that would have been put into the buffer
+ * had it been large enough, if the string is truncated.
+ * The only way to get that value is to use _vscprintf();
+ * getting that count isn't worth the re-formatting.
+ *
+ * XXX - does _vsnprintf_s() return -1 on a formatting
+ * error?
*/
str[str_size - 1] = '\0';
return (ret);