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, "\?\?="); } }