From 80dd6cc143c3be518b4972221623322069de456f Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Mon, 3 Jun 2019 08:34:51 -0600 Subject: [PATCH 1/2] Check correct allocation assignment. Thanks to R.A. for the report on ZD-5154 --- wolfcrypt/src/pwdbased.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index e0edf6e3a..7cf18ceb1 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -198,7 +198,7 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, if (buffer == NULL) return MEMORY_E; hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_HMAC); - if (buffer == NULL) + if (hmac == NULL) return MEMORY_E; #endif From 290663f8b298e3d8b70567d8cda86b068a9c7e1e Mon Sep 17 00:00:00 2001 From: Kaleb Himes Date: Mon, 3 Jun 2019 15:13:02 -0600 Subject: [PATCH 2/2] Feedback changes implemented --- wolfcrypt/src/pwdbased.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index 7cf18ceb1..a5200d8de 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -198,8 +198,10 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, if (buffer == NULL) return MEMORY_E; hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_HMAC); - if (hmac == NULL) + if (hmac == NULL) { + XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; + } #endif ret = wc_HmacInit(hmac, NULL, INVALID_DEVID);