aboutsummaryrefslogtreecommitdiff
path: root/src/tss2-esys
diff options
context:
space:
mode:
authorJuergen Repp <Juergen.Repp@sit.fraunhofer.de>2018-11-26 15:22:27 +0100
committerAndreas Fuchs <andreas.fuchs@sit.fraunhofer.de>2018-12-03 11:54:23 +0100
commita5cdca085b5c2c20b0dfb5bebb27bf8248d12c81 (patch)
treec63e9dc630a5bb6c033765b0ab115644895f1d35 /src/tss2-esys
parentebc2df274b94a34b3881ddd950d7c73fc4e38884 (diff)
downloadtpm2-tss-a5cdca085b5c2c20b0dfb5bebb27bf8248d12c81.tar.gz
ESYS: Remove unnecessary size check in StartAuthSession
The check whether the secret size is zero can be removed because size zero is possible if no tpmKey for encryption is used and the authValue of the bind object has length 0. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
Diffstat (limited to 'src/tss2-esys')
-rw-r--r--src/tss2-esys/api/Esys_StartAuthSession.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tss2-esys/api/Esys_StartAuthSession.c b/src/tss2-esys/api/Esys_StartAuthSession.c
index 6ea60c41..0ea2829a 100644
--- a/src/tss2-esys/api/Esys_StartAuthSession.c
+++ b/src/tss2-esys/api/Esys_StartAuthSession.c
@@ -450,11 +450,11 @@ Esys_StartAuthSession_Finish(
secret_size += keyHash_size;
if (bind != ESYS_TR_NONE && bindNode != NULL)
secret_size += bindNode->auth.size;
- if (secret_size == 0) {
- return_error(TSS2_ESYS_RC_GENERAL_FAILURE,
- "Invalid secret size (0).");
- }
- uint8_t *secret = malloc(secret_size);
+ /*
+ * A non null pointer for secret is required by the subsequent functions,
+ * hence a malloc is called with size 1 if secret_size is zero.
+ */
+ uint8_t *secret = malloc(secret_size ? secret_size : 1);
if (secret == NULL) {
LOG_ERROR("Out of memory.");
return TSS2_ESYS_RC_MEMORY;