Browse Source

[crypto] Check that common name contains no NUL characters

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
6c8fcd4bb3
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/crypto/x509.c

+ 9
- 0
src/crypto/x509.c View File

@@ -575,6 +575,15 @@ static int x509_parse_common_name ( struct x509_certificate *cert, char **name,
575 575
 		if ( ! *name )
576 576
 			return -ENOMEM;
577 577
 		memcpy ( *name, name_cursor.data, name_cursor.len );
578
+
579
+		/* Check that name contains no NULs */
580
+		if ( strlen ( *name ) != name_cursor.len ) {
581
+			DBGC ( cert, "X509 %p contains malicious commonName:\n",
582
+			       cert );
583
+			DBGC_HDA ( cert, 0, raw->data, raw->len );
584
+			return rc;
585
+		}
586
+
578 587
 		return 0;
579 588
 	}
580 589
 

Loading…
Cancel
Save