]> The Tcpdump Group git mirrors - libpcap/commitdiff
Fix the size argument to _wcserror_s().
authorGuy Harris <[email protected]>
Sat, 11 Apr 2020 22:20:56 +0000 (15:20 -0700)
committerGuy Harris <[email protected]>
Sat, 11 Apr 2020 22:20:56 +0000 (15:20 -0700)
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".

fmtutils.c

index 8f6921fbc0467ce7dfdb5c7c116e3f0c6a2037c9..4f0ebe90e68eec4b59096f06fcb09b4faf358112 100644 (file)
@@ -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