Prevent output of escaped null characters dn gets

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
This commit is contained in:
Agathiyan Bragadeesh 2023-08-22 16:56:04 +01:00
parent d9d79bb74b
commit 022f86f108

View file

@ -919,7 +919,10 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn)
c = name->val.p[i];
// Special characters requiring escaping, RFC 4514 Section 2.4
if (c) {
if (c == '\0') {
return MBEDTLS_ERR_X509_INVALID_NAME;
}
else {
if (strchr(",=+<>;\"\\", c) ||
((i == 0) && strchr("# ", c)) ||
((i == name->val.len-1) && (c == ' '))) {