fixed some more memory leaks

This commit is contained in:
Andreas Steffen
2011-11-28 21:22:51 +01:00
parent b2485f321d
commit 3186b04c0b
2 changed files with 17 additions and 21 deletions
@@ -377,12 +377,10 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
"support sub component measurements"); "support sub component measurements");
return FALSE; return FALSE;
} }
name = name->clone(name);
comp = pts_components->create(pts_components, name); comp = pts_components->create(pts_components, name);
if (!comp) if (!comp)
{ {
DBG2(DBG_IMC, " not registered: no evidence provided"); DBG2(DBG_IMC, " not registered: no evidence provided");
name->destroy(name);
continue; continue;
} }
+17 -19
View File
@@ -713,19 +713,19 @@ METHOD(pts_t, get_metadata, pts_file_meta_t*,
} }
METHOD(pts_t, read_pcr, bool, METHOD(pts_t, read_pcr, bool,
private_pts_t *this, u_int32_t pcr_num, chunk_t *output) private_pts_t *this, u_int32_t pcr_num, chunk_t *pcr_value)
{ {
TSS_HCONTEXT hContext; TSS_HCONTEXT hContext;
TSS_HTPM hTPM; TSS_HTPM hTPM;
TSS_RESULT result; TSS_RESULT result;
u_int32_t pcr_length; chunk_t rgbPcrValue;
chunk_t pcr_value;
bool success = FALSE;
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result);
result);
return FALSE; return FALSE;
} }
@@ -739,26 +739,24 @@ METHOD(pts_t, read_pcr, bool,
{ {
goto err; goto err;
} }
pcr_value = chunk_alloc(PCR_LEN); result = Tspi_TPM_PcrRead(hTPM, pcr_num, &rgbPcrValue.len, &rgbPcrValue.ptr);
result = Tspi_TPM_PcrRead(hTPM, pcr_num, &pcr_length, &pcr_value.ptr);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
goto err; goto err;
} }
*pcr_value = chunk_clone(rgbPcrValue);
DBG3(DBG_PTS, "PCR %d value:%B", pcr_num, pcr_value);
success = TRUE;
*output = pcr_value; err:
*output = chunk_clone(*output); if (!success)
{
chunk_clear(&pcr_value); DBG1(DBG_PTS, "TPM not available: tss error 0x%x", result);
DBG3(DBG_PTS, "PCR %d value:%B", pcr_num, output); }
Tspi_Context_FreeMemory(hContext, NULL);
Tspi_Context_Close(hContext); Tspi_Context_Close(hContext);
return TRUE;
err: return success;
chunk_clear(&pcr_value);
DBG1(DBG_PTS, "TPM not available: tss error 0x%x", result);
Tspi_Context_Close(hContext);
return FALSE;
} }
METHOD(pts_t, extend_pcr, bool, METHOD(pts_t, extend_pcr, bool,
@@ -933,7 +931,7 @@ METHOD(pts_t, quote_tpm, bool,
/* TPM Quote */ /* TPM Quote */
result = use_quote2 ? result = use_quote2 ?
Tspi_TPM_Quote2(hTPM, hAIK, FALSE, hPcrComposite, &valData, Tspi_TPM_Quote2(hTPM, hAIK, FALSE, hPcrComposite, &valData,
&versionInfoSize,&versionInfo): &versionInfoSize, &versionInfo):
Tspi_TPM_Quote(hTPM, hAIK, hPcrComposite, &valData); Tspi_TPM_Quote(hTPM, hAIK, hPcrComposite, &valData);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {