From 47158417dd447d2c6b878aa24e14b1dd069e852b Mon Sep 17 00:00:00 2001 From: Mario Klebsch Date: Wed, 1 Oct 2025 13:29:47 +0200 Subject: [PATCH] Increased MBEDTLS_BEFORE_COLON (size of temporary buffer) to 32 --- library/x509_crt.c | 3 ++- library/x509_csr.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/library/x509_crt.c b/library/x509_crt.c index e6b9252859b1..83d078a33ae9 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1744,7 +1744,7 @@ static int x509_info_cert_policies(char **buf, size_t *size, /* * Return an informational string about the certificate. */ -#define MBEDTLS_BEFORE_COLON 18 +#define MBEDTLS_BEFORE_COLON 32 #define MBEDTLS_BEFORE_COLON_STR "18" int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix, const mbedtls_x509_crt *crt) @@ -1807,6 +1807,7 @@ int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix, /* Key size */ if ((ret = mbedtls_x509_key_size_helper(key_size_str, MBEDTLS_BEFORE_COLON, mbedtls_pk_get_name(&crt->pk))) != 0) { + assert(ret != MBEDTLS_ERR_X509_BUFFER_TOO_SMALL); return ret; } diff --git a/library/x509_csr.c b/library/x509_csr.c index 32a3bb2e78ec..0462ee9f8236 100644 --- a/library/x509_csr.c +++ b/library/x509_csr.c @@ -519,7 +519,7 @@ int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path) #endif /* MBEDTLS_FS_IO */ #if !defined(MBEDTLS_X509_REMOVE_INFO) -#define MBEDTLS_BEFORE_COLON 14 +#define MBEDTLS_BEFORE_COLON 32 #define MBEDTLS_BEFORE_COLON_STR "14" /* * Return an informational string about the CSR. @@ -552,6 +552,7 @@ int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix, if ((ret = mbedtls_x509_key_size_helper(key_size_str, MBEDTLS_BEFORE_COLON, mbedtls_pk_get_name(&csr->pk))) != 0) { + assert(ret != MBEDTLS_ERR_X509_BUFFER_TOO_SMALL); return ret; }