Revision: 19557
          http://sourceforge.net/p/edk2/code/19557
Author:   vanjeff
Date:     2015-12-29 03:12:05 +0000 (Tue, 29 Dec 2015)
Log Message:
-----------
CryptoPkg/BaseCryptLib: Use accessor functions for X509_ATTRIBUTE

In OpenSSL 1.1, the X509_ATTRIBUTE becomes an opaque structure and we will
no longer get away with accessing its members directly. Use the accessor
functions X509_ATTRIBUTE_get0_object0() and X509_ATTRIBUTE_get0_type()
instead.

Also be slightly more defensive about unlikely failure modes.

(Sync patch r18700 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <[email protected]>
Tested-by: Laszlo Ersek <[email protected]>
Reviewed-by: Qin Long <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/18700

Modified Paths:
--------------
    branches/UDK2015/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c

Modified: branches/UDK2015/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c
===================================================================
--- branches/UDK2015/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c        
2015-12-29 03:11:37 UTC (rev 19556)
+++ branches/UDK2015/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c        
2015-12-29 03:12:05 UTC (rev 19557)
@@ -613,6 +613,7 @@
   UINTN                        Index;
   STACK_OF(X509_ATTRIBUTE)     *Sk;
   X509_ATTRIBUTE               *Xa;
+  ASN1_OBJECT                  *XaObj;
   ASN1_TYPE                    *Asn1Type;
   ASN1_OCTET_STRING            *EncDigest;
   UINT8                        *TSToken;
@@ -692,11 +693,18 @@
     // Search valid RFC3161 timestamp counterSignature based on OBJID.
     //
     Xa = sk_X509_ATTRIBUTE_value (Sk, (int)Index);
-    if ((Xa->object->length != sizeof (mSpcRFC3161OidValue)) ||
-        (CompareMem (Xa->object->data, mSpcRFC3161OidValue, sizeof 
(mSpcRFC3161OidValue)) != 0)) {
+    if (Xa == NULL) {
       continue;
     }
-    Asn1Type = sk_ASN1_TYPE_value (Xa->value.set, 0);
+    XaObj = X509_ATTRIBUTE_get0_object(Xa);
+    if (XaObj == NULL) {
+      continue;
+    }
+    if ((XaObj->length != sizeof (mSpcRFC3161OidValue)) ||
+        (CompareMem (XaObj->data, mSpcRFC3161OidValue, sizeof 
(mSpcRFC3161OidValue)) != 0)) {
+      continue;
+    }
+    Asn1Type = X509_ATTRIBUTE_get0_type(Xa, 0);
   }
 
   if (Asn1Type == NULL) {


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to