Skip to content

Commit 50e4110

Browse files
Alternate fix for CVE-2025-69419
This affects the function OPENSSL_uni2utf8 which caused heap buffer overflow when certain unicode characters are converted. The current fix is incomplete and does only prevent the crash by making OPENSSL_uni2utf8 return a NULL pointer. But with this change the OPENSSL_uni2utf8 will return the correct utf8 string instead of a NULL pointer. Additionally we add a simple test case that demonstrates the original CVE.
1 parent 74d47c8 commit 50e4110

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

crypto/pkcs12/p12_utl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static int bmp_to_utf8(char *str, const unsigned char *utf16, int len)
175175
utf32chr += 0x10000;
176176
}
177177

178-
return UTF8_putc((unsigned char *)str, len > 4 ? 4 : len, utf32chr);
178+
return UTF8_putc((unsigned char *)str, 4, utf32chr);
179179
}
180180

181181
char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen)

test/asn1_internal_test.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <openssl/asn1.h>
2222
#include <openssl/evp.h>
23+
#include <openssl/pkcs12.h>
2324
#include <openssl/objects.h>
2425
#include <openssl/posix_time.h>
2526
#include "testutil.h"
@@ -570,6 +571,25 @@ static int test_mbstring_ncopy(void)
570571
return 1;
571572
}
572573

574+
static int test_ossl_uni2utf8(void)
575+
{
576+
const unsigned char in[] = { 0x21, 0x92 }; /* unicode right arrow */
577+
int inlen = 2;
578+
char *out = NULL;
579+
int ok = 0;
580+
581+
/* reproducer for CVE-2025-69419 */
582+
out = OPENSSL_uni2utf8(in, inlen);
583+
if (!TEST_str_eq(out, "\xe2\x86\x92"))
584+
goto err;
585+
586+
ok = 1;
587+
588+
err:
589+
OPENSSL_free(out);
590+
return ok;
591+
}
592+
573593
int setup_tests(void)
574594
{
575595
ADD_TEST(test_tbl_standard);
@@ -582,5 +602,6 @@ int setup_tests(void)
582602
ADD_TEST(posix_time_test);
583603
ADD_TEST(test_asn1_time_tm_conversions);
584604
ADD_TEST(test_mbstring_ncopy);
605+
ADD_TEST(test_ossl_uni2utf8);
585606
return 1;
586607
}

0 commit comments

Comments
 (0)