]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Test invalid out of range character handling in UTF8_getc()
authorTomas Mraz <tomas@openssl.org>
Tue, 11 Nov 2025 09:11:44 +0000 (10:11 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 14 Nov 2025 08:18:00 +0000 (09:18 +0100)
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29119)

test/asn1_internal_test.c

index d4a2bb10ba7e4ddadefed45e2c791da13c23327b..55bc92cb6448f9152e8ea37dac5f67a7c7cdda6d 100644 (file)
@@ -191,6 +191,16 @@ static int test_unicode_range(void)
     return ok;
 }
 
+static int test_invalid_utf8(void)
+{
+    const unsigned char inv_utf8[] = "\xF4\x90\x80\x80";
+    unsigned long val;
+
+    if (!TEST_int_lt(UTF8_getc(inv_utf8, sizeof(inv_utf8), &val), 0))
+        return 0;
+    return 1;
+}
+
 /**********************************************************************
  *
  * Tests of object creation
@@ -551,6 +561,7 @@ int setup_tests(void)
     ADD_TEST(test_standard_methods);
     ADD_TEST(test_empty_nonoptional_content);
     ADD_TEST(test_unicode_range);
+    ADD_TEST(test_invalid_utf8);
     ADD_TEST(test_obj_create);
     ADD_TEST(test_obj_nid_undef);
     ADD_TEST(posix_time_test);