mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-05 09:15:54 +00:00
tpm12: Get rid of usage of sprintf and use snprintf instead
Get rid of the usage of an sprintf and use snprintf instead. In this case the buffer is 128, so big enough to not cause problems, though. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
7bd2fb0d42
commit
57d628a5ce
@ -627,8 +627,14 @@ TPM_RESULT TPM_Process_GetTestResult(tpm_state_t *tpm_state,
|
||||
}
|
||||
/* for now, just return the state of shutdown as a printable string */
|
||||
if (returnCode == TPM_SUCCESS) {
|
||||
/* cast because TPM_SIZED_BUFFER is typically unsigned (binary) but sprintf expects char */
|
||||
outData.size = sprintf((char *)(outData.buffer), "Shutdown %08x\n", tpm_state->testState);
|
||||
size_t len = outData.size;
|
||||
/* cast because TPM_SIZED_BUFFER is typically unsigned (binary) but snprintf expects char */
|
||||
outData.size = snprintf((char *)(outData.buffer), len,
|
||||
"Shutdown %08x\n", tpm_state->testState);
|
||||
if (outData.size >= len) {
|
||||
printf("TPM_Process_GetTestResult: Error (fatal), buffer too small\n");
|
||||
returnCode = TPM_FAIL;
|
||||
}
|
||||
}
|
||||
/*
|
||||
response
|
||||
|
||||
Loading…
Reference in New Issue
Block a user