From f59f10f1d1d6954dfcd87f5ba76125620424c380 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Tue, 12 Sep 2023 15:56:27 +0100 Subject: [PATCH] Add error returns in utf validator Signed-off-by: Agathiyan Bragadeesh --- library/x509_create.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/x509_create.c b/library/x509_create.c index d02b526802..a0d04a76ab 100644 --- a/library/x509_create.c +++ b/library/x509_create.c @@ -254,7 +254,7 @@ static int validate_utf8(unsigned char *data, size_t len) utf_bytes = 4; code_point = code_point | (uint32_t) (*d & 0x07) << 18; } else { - return MBEDTLS_ERROR_C; + return MBEDTLS_ERR_X509_INVALID_NAME; } for (i = utf_bytes-1; i > 0; i--) { if (d + 1 >= end) { @@ -266,18 +266,18 @@ static int validate_utf8(unsigned char *data, size_t len) switch (utf_bytes) { case 2: if (!(0x80 < code_point && code_point < 0x7FF)) { - return MBEDTLS_ERROR_C; //bad encoding + return MBEDTLS_ERR_X509_INVALID_NAME; //bad encoding } break; case 3: if (!(0x800 < code_point && code_point < 0xD7FF) && !(0xE000 < utf_bytes && utf_bytes < 0xFFFF)) { - return MBEDTLS_ERROR_C; //bad encoding + return MBEDTLS_ERR_X509_INVALID_NAME; //bad encoding } break; case 4: if (!(0x10000 < code_point && code_point < 0x10FFFF)) { - return MBEDTLS_ERROR_C; //bad encoding + return MBEDTLS_ERR_X509_INVALID_NAME; //bad encoding } break; }