- Handle empty certificate subject names
diff --git a/ChangeLog b/ChangeLog
index 4fbd4b6..993bbea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,7 @@
#52)
* Handle encryption with private key and decryption with public key as per
RFC 2313
+ * Handle empty certificate subject names
Security
* Fixed potential memory corruption on miscrafted client messages (found by
diff --git a/library/x509parse.c b/library/x509parse.c
index 883ea25..a43c6d4 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -1263,7 +1263,7 @@
return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret );
}
- if( ( ret = x509_get_name( &p, p + len, &crt->subject ) ) != 0 )
+ if( len && ( ret = x509_get_name( &p, p + len, &crt->subject ) ) != 0 )
{
x509_free( crt );
return( ret );
@@ -2518,6 +2518,12 @@
while( name != NULL )
{
+ if( !name->oid.p )
+ {
+ name = name->next;
+ continue;
+ }
+
if( name != dn )
{
ret = snprintf( p, n, ", " );