Преглед изворни кода

[crypto] Accept UTCTime/GeneralizedTime with no "seconds" field

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown пре 13 година
родитељ
комит
f20c3742e7
1 измењених фајлова са 6 додато и 0 уклоњено
  1. 6
    0
      src/crypto/asn1.c

+ 6
- 0
src/crypto/asn1.c Прегледај датотеку

655
 	}
655
 	}
656
 
656
 
657
 	/* Parse digit string a pair at a time */
657
 	/* Parse digit string a pair at a time */
658
+	memset ( &pairs, 0, sizeof ( pairs ) );
658
 	data = contents.data;
659
 	data = contents.data;
659
 	remaining = contents.len;
660
 	remaining = contents.len;
660
 	for ( i = ( have_century ? 0 : 1 ) ; i < sizeof ( pairs.raw ) ; i++ ) {
661
 	for ( i = ( have_century ? 0 : 1 ) ; i < sizeof ( pairs.raw ) ; i++ ) {
661
 		if ( remaining < 2 ) {
662
 		if ( remaining < 2 ) {
663
+			/* Some certificates violate the X.509 RFC by
664
+			 * omitting the "seconds" value.
665
+			 */
666
+			if ( i == ( sizeof ( pairs.raw ) - 1 ) )
667
+				break;
662
 			DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
668
 			DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
663
 			DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
669
 			DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
664
 			return -EINVAL_ASN1_TIME;
670
 			return -EINVAL_ASN1_TIME;

Loading…
Откажи
Сачувај