Skip to content

Commit 5bb1260

Browse files
Add wc_Sha256Free after the final use
1 parent 91cbb64 commit 5bb1260

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/agent.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ static int PostAddRsaId(WOLFSSH_AGENT_CTX* agent,
436436
ret = wc_Sha256Update(&sha, key, nSz + eSz + (LENGTH_SZ * 2));
437437
if (ret == 0)
438438
ret = wc_Sha256Final(&sha, id->id);
439+
wc_Sha256Free(&sha);
439440

440441
if (ret == 0)
441442
ret = WS_SUCCESS;
@@ -518,6 +519,7 @@ static int PostAddEcdsaId(WOLFSSH_AGENT_CTX* agent,
518519
curveNameSz + qSz + (LENGTH_SZ * 2));
519520
if (ret == 0)
520521
ret = wc_Sha256Final(&sha, id->id);
522+
wc_Sha256Free(&sha);
521523

522524
if (ret == 0)
523525
ret = WS_SUCCESS;
@@ -584,6 +586,7 @@ static int PostRemoveId(WOLFSSH_AGENT_CTX* agent,
584586
ret = wc_Sha256Update(&sha, keyBlob, keyBlobSz);
585587
if (ret == 0)
586588
ret = wc_Sha256Final(&sha, id);
589+
wc_Sha256Free(&sha);
587590
ret = (ret == 0) ? WS_SUCCESS : WS_CRYPTO_FAILED;
588591
}
589592

@@ -661,6 +664,10 @@ static WOLFSSH_AGENT_ID* FindKeyId(WOLFSSH_AGENT_ID* id,
661664
ret = wc_Sha256Final(&sha, digest);
662665
ret = (ret == 0) ? WS_SUCCESS : WS_CRYPTO_FAILED;
663666
}
667+
else {
668+
ret = WS_CRYPTO_FAILED;
669+
}
670+
wc_Sha256Free(&sha);
664671

665672
if (ret == WS_SUCCESS) {
666673
while (id != NULL &&
@@ -669,6 +676,9 @@ static WOLFSSH_AGENT_ID* FindKeyId(WOLFSSH_AGENT_ID* id,
669676
id = id->next;
670677
}
671678
}
679+
else {
680+
id = NULL;
681+
}
672682

673683
return id;
674684
}

0 commit comments

Comments
 (0)