From 4beb1d2bac46a712664adc4ab51196215bb65ca8 Mon Sep 17 00:00:00 2001 From: apldev4 Date: Tue, 14 May 2019 11:08:40 -0400 Subject: [PATCH] [#135] tpm_version prints output containing nulls. (#137) The tpm_version tool can sometimes print a null value as part of the TPM major version if the major version is less than 4 characters. These nulls are now removed before printing. --- HIRS_ProvisionerTPM2/src/tpm_version.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HIRS_ProvisionerTPM2/src/tpm_version.cpp b/HIRS_ProvisionerTPM2/src/tpm_version.cpp index 6729d6a2..2c18ea35 100644 --- a/HIRS_ProvisionerTPM2/src/tpm_version.cpp +++ b/HIRS_ProvisionerTPM2/src/tpm_version.cpp @@ -114,6 +114,9 @@ class SapiContext { string reversedStringValue(UINT32 value) { string stringValue(sizeof value, 0); std::memcpy(&stringValue[0], &value, stringValue.size()); // copy bytes in + // get rid of all contained null values + stringValue.erase(std::remove(stringValue.begin(), stringValue.end(), '\0'), + stringValue.end()); std::reverse(stringValue.begin(), stringValue.end()); // reverse the bytes return stringValue; }