fix: correct UTF-8 continuation byte validation

This commit is contained in:
wangtsiao
2026-06-12 19:03:04 -10:00
parent 23375d1fa3
commit 80081c24eb
2 changed files with 9 additions and 1 deletions

View File

@@ -500,7 +500,10 @@ static int test_asn1_utf8_string(void)
"hello",
"world",
"Just do it!",
"J\303\274rgen",
"\344\270\255",
};
const char invalid_utf8[] = { (char)0xc3, 'A' };
uint8_t buf[256];
uint8_t *p = buf;
const uint8_t *cp = buf;
@@ -530,6 +533,10 @@ static int test_asn1_utf8_string(void)
error_print();
return -1;
}
if (asn1_string_is_utf8_string(invalid_utf8, sizeof(invalid_utf8)) != 0) {
error_print();
return -1;
}
printf("%s() ok\n", __FUNCTION__);
return 1;
}
@@ -841,6 +848,7 @@ static int test_asn1_from_der_null_args(void)
int main(void)
{
if (test_asn1_tag() != 1) goto err;
if (test_asn1_utf8_string() != 1) goto err;
/*
if (test_asn1_length() != 1) goto err;
if (test_asn1_length_from_ber() != 1) goto err;