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