summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMichael Brown2012-05-08 11:38:04 +0200
committerMichael Brown2012-05-08 13:49:01 +0200
commit6c8fcd4bb31d2c4da90e94d78363182d1e92a6c7 (patch)
treeef5c7a9d22eb645a628909657fc015f4f202fe76 /src/crypto
parent[crypto] Allow for X.509 certificates with no common name (diff)
downloadipxe-6c8fcd4bb31d2c4da90e94d78363182d1e92a6c7.tar.gz
ipxe-6c8fcd4bb31d2c4da90e94d78363182d1e92a6c7.tar.xz
ipxe-6c8fcd4bb31d2c4da90e94d78363182d1e92a6c7.zip
[crypto] Check that common name contains no NUL characters
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/x509.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/crypto/x509.c b/src/crypto/x509.c
index 3261b8eb..356b60a3 100644
--- a/src/crypto/x509.c
+++ b/src/crypto/x509.c
@@ -575,6 +575,15 @@ static int x509_parse_common_name ( struct x509_certificate *cert, char **name,
if ( ! *name )
return -ENOMEM;
memcpy ( *name, name_cursor.data, name_cursor.len );
+
+ /* Check that name contains no NULs */
+ if ( strlen ( *name ) != name_cursor.len ) {
+ DBGC ( cert, "X509 %p contains malicious commonName:\n",
+ cert );
+ DBGC_HDA ( cert, 0, raw->data, raw->len );
+ return rc;
+ }
+
return 0;
}