Pārlūkot izejas kodu

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 gadus atpakaļ
vecāks
revīzija
f20c3742e7
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. 6
    0
      src/crypto/asn1.c

+ 6
- 0
src/crypto/asn1.c Parādīt failu

@@ -655,10 +655,16 @@ int asn1_generalized_time ( const struct asn1_cursor *cursor, time_t *time ) {
655 655
 	}
656 656
 
657 657
 	/* Parse digit string a pair at a time */
658
+	memset ( &pairs, 0, sizeof ( pairs ) );
658 659
 	data = contents.data;
659 660
 	remaining = contents.len;
660 661
 	for ( i = ( have_century ? 0 : 1 ) ; i < sizeof ( pairs.raw ) ; i++ ) {
661 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 668
 			DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
663 669
 			DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
664 670
 			return -EINVAL_ASN1_TIME;

Notiek ielāde…
Atcelt
Saglabāt