From 8afa70dcd5a777b792064fd05f6ff6e17bf26f87 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 11 Feb 2012 18:42:45 +0000
Subject: [PATCH] - Clean Subject Alternative Name data
---
library/x509parse.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/library/x509parse.c b/library/x509parse.c
index 28526435c..4913bec01 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -497,6 +497,10 @@ static int x509_get_sig( unsigned char **p,
int ret;
size_t len;
+ if( ( end - *p ) < 1 )
+ return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE +
+ POLARSSL_ERR_ASN1_OUT_OF_DATA );
+
sig->tag = **p;
if( ( ret = asn1_get_tag( p, end, &len, ASN1_BIT_STRING ) ) != 0 )
@@ -3215,6 +3219,15 @@ void x509_free( x509_cert *crt )
free( seq_prv );
}
+ seq_cur = cert_cur->subject_alt_names.next;
+ while( seq_cur != NULL )
+ {
+ seq_prv = seq_cur;
+ seq_cur = seq_cur->next;
+ memset( seq_prv, 0, sizeof( x509_sequence ) );
+ free( seq_prv );
+ }
+
if( cert_cur->raw.p != NULL )
{
memset( cert_cur->raw.p, 0, cert_cur->raw.len );