From: Guy Harris Date: Sat, 11 Apr 2020 22:20:56 +0000 (-0700) Subject: Fix the size argument to _wcserror_s(). X-Git-Tag: libpcap-1.10-bp~226 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/624fc6eb6657457b6f118b9693be87dc6f3713cc Fix the size argument to _wcserror_s(). It's not well documented, but it's called numberOfElements, which I *assume* means "number of elements in the array", not "size of the array in bytes". --- diff --git a/fmtutils.c b/fmtutils.c index 8f6921fb..4f0ebe90 100644 --- a/fmtutils.c +++ b/fmtutils.c @@ -101,7 +101,8 @@ pcap_fmt_set_encoding(unsigned int opts _U_) #define REPLACEMENT_CHARACTER 0x0FFFD static char * -utf_16le_to_utf_8_truncated(wchar_t *utf_16, char *utf_8, size_t utf_8_len) +utf_16le_to_utf_8_truncated(const wchar_t *utf_16, char *utf_8, + size_t utf_8_len) { wchar_t c, c2; uint32_t uc; @@ -302,7 +303,7 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, * Generate a UTF-16LE error message. */ wchar_t utf_16_errbuf[PCAP_ERRBUF_SIZE]; - errno_t err = _wcserror_s(utf_16_errbuf, sizeof (utf_16_errbuf), errnum); + errno_t err = _wcserror_s(utf_16_errbuf, PCAP_ERRBUF_SIZE, errnum); if (err != 0) { /* * It doesn't appear to be documented anywhere obvious