chantra / rpms / tpm2-tools

Forked from rpms/tpm2-tools 2 years ago
Clone

Blame SOURCES/tpm2_getmanuc-null-check.patch

a5f4ba
diff -ur tpm2.0-tools-1.1.0/src/tpm2_getmanufec.cpp tpm2.0-tools-1.1.0-new/src/tpm2_getmanufec.cpp
a5f4ba
--- tpm2.0-tools-1.1.0/src/tpm2_getmanufec.cpp	2017-04-05 15:47:18.271030008 -0700
a5f4ba
+++ tpm2.0-tools-1.1.0-new/src/tpm2_getmanufec.cpp	2017-04-05 15:47:39.326377029 -0700
a5f4ba
@@ -332,9 +332,16 @@
a5f4ba
 
a5f4ba
 char *Base64Encode(const unsigned char* buffer)
a5f4ba
 {
a5f4ba
-    printf("Calculating the Base64Encode of the hash of the Endorsement Public Key:\n");
a5f4ba
     BIO *bio, *b64;
a5f4ba
     BUF_MEM *bufferPtr;
a5f4ba
+
a5f4ba
+    printf("Calculating the Base64Encode of the hash of the Endorsement Public Key:\n");
a5f4ba
+
a5f4ba
+    if (buffer == NULL) {
a5f4ba
+	    printf("HashEKPublicKey returned null\n");
a5f4ba
+	    return NULL;
a5f4ba
+    }
a5f4ba
+
a5f4ba
     b64 = BIO_new(BIO_f_base64());
a5f4ba
     bio = BIO_new(BIO_s_mem());
a5f4ba
     bio = BIO_push(b64, bio);
a5f4ba
@@ -371,6 +378,12 @@
a5f4ba
 int RetrieveEndorsementCredentials(char *b64h)
a5f4ba
 {
a5f4ba
     printf("Retrieving Endorsement Credential Certificate from the TPM Manufacturer EK Provisioning Server\n");
a5f4ba
+
a5f4ba
+    if (b64h == NULL) {
a5f4ba
+	    printf("Base64Encode returned null\n");
a5f4ba
+	    return -1;
a5f4ba
+    }
a5f4ba
+
a5f4ba
     char *weblink = (char*)malloc(1 + strlen(b64h) + strlen(EKserverAddr));
a5f4ba
     memset(weblink, 0, (1 + strlen(b64h) + strlen(EKserverAddr)));
a5f4ba
     strcat(weblink, EKserverAddr);
a5f4ba
@@ -416,8 +429,7 @@
a5f4ba
         printf("TPM Manufacturer Endorsement Credential Server Address cannot be NULL\n");
a5f4ba
         return -99;
a5f4ba
     }
a5f4ba
-    RetrieveEndorsementCredentials(Base64Encode(HashEKPublicKey()));
a5f4ba
-    return 0;
a5f4ba
+    return RetrieveEndorsementCredentials(Base64Encode(HashEKPublicKey()));
a5f4ba
 }
a5f4ba
 
a5f4ba
 void showHelp(const char *name)