← Commit list

be76b32aed

Viktor Szakats
Viktor Szakats
2025-12-16
SUCCESS Duration: 215s

Subject

idn: clarify null-termination on Windows

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/idn.c+6 -0
@@ -185,6 +185,9 @@ static CURLcode win32_idn_to_ascii(const char *in, char **out)
wchar_t in_w[IDN_MAX_LENGTH];
int in_w_len;
*out = NULL;
+ /* Returned in_w_len includes the null-terminator, which then gets
+ preserved across the calls that follow, ending up terminating
+ the buffer returned to the caller. */
in_w_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, in_w, IDN_MAX_LENGTH);
if(in_w_len) {
wchar_t punycode[IDN_MAX_LENGTH];
@@ -208,6 +211,9 @@ static CURLcode win32_ascii_to_idn(const char *in, char **out)
wchar_t in_w[IDN_MAX_LENGTH];
int in_w_len;
*out = NULL;
+ /* Returned in_w_len includes the null-terminator, which then gets
+ preserved across the calls that follow, ending up terminating
+ the buffer returned to the caller. */
in_w_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, in_w, IDN_MAX_LENGTH);
if(in_w_len) {
WCHAR idn[IDN_MAX_LENGTH]; /* stores a UTF-16 string */