Skip to content

Commit c753000

Browse files
committed
GHSL-2023-013: Memory corruption decoding UTF16
Memory corruption when decoding UTF16 strings (GHSL-2023-013) Fixes defect GHSL-2023-013 found by the GitHub Security Lab team via oss-fuzz. The variable outlen was not initialized and could cause writing a zero to an arbitrary place in memory if ntlm_str_convert() were to fail, which would leave outlen uninitialized. This can lead to a DoS if the write hits unmapped memory or randomly corrupting a byte in the application memory space. Make sure to zero out only if ntlm_str_convert() succeeds, but for good measure also initialize outlen to 0. Fixes CVE-2023-25564 Signed-off-by: Simo Sorce <simo@redhat.com>
1 parent 97c62c6 commit c753000

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ntlm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static int ntlm_decode_u16l_str_hdr(struct ntlm_ctx *ctx,
299299
char *in, *out = NULL;
300300
uint16_t str_len;
301301
uint32_t str_offs;
302-
size_t outlen;
302+
size_t outlen = 0;
303303
int ret = 0;
304304

305305
str_len = le16toh(str_hdr->len);
@@ -320,13 +320,14 @@ static int ntlm_decode_u16l_str_hdr(struct ntlm_ctx *ctx,
320320

321321
ret = ntlm_str_convert(ctx->to_oem, in, out, str_len, &outlen);
322322

323-
/* make sure to terminate output string */
324-
out[outlen] = '\0';
325-
326323
done:
327324
if (ret) {
328325
safefree(out);
326+
} else {
327+
/* make sure to terminate output string */
328+
out[outlen] = '\0';
329329
}
330+
330331
*str = out;
331332
return ret;
332333
}

0 commit comments

Comments
 (0)