]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[crypto] Check that common name contains no NUL characters
authorMichael Brown <mcb30@ipxe.org>
Tue, 8 May 2012 09:38:04 +0000 (10:38 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 May 2012 11:49:01 +0000 (12:49 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/crypto/x509.c

index 3261b8eb686b9a6dfeeb1498bade4cb652074670..356b60a368998105f881f0a4f6840bbb06111e7a 100644 (file)
@@ -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;
        }