From 8aa74ab6a9c820ba44469f293c954cdaaafc9292 Mon Sep 17 00:00:00 2001 From: Agathiyan Bragadeesh Date: Tue, 22 Aug 2023 16:42:27 +0100 Subject: [PATCH] Add return for buffer too small when reading OIDs Signed-off-by: Agathiyan Bragadeesh --- library/x509.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/x509.c b/library/x509.c index 446bf249a8..f574055e10 100644 --- a/library/x509.c +++ b/library/x509.c @@ -865,7 +865,10 @@ int mbedtls_x509_dn_gets(char *buf, size_t size, const mbedtls_x509_name *dn) p += ret; ret = mbedtls_snprintf(p, n, "="); print_hexstring = 1; - } else { + } else if (ret == MBEDTLS_ERR_OID_BUF_TOO_SMALL) { + return MBEDTLS_ERR_X509_BUFFER_TOO_SMALL; + } + else { ret = mbedtls_snprintf(p, n, "\?\?="); } }