Skip to content

Commit aa97454

Browse files
padelsbachejohnstown
authored andcommitted
Fix uninit variable in KeyAgreeEcdh_server
1 parent 1cb644d commit aa97454

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,9 @@ static int GetOpenSshKeyEd25519(ed25519_key* key,
17511751
ret = GetStringRef(&pubSz, &pub, buf, len, idx); /* ENC(A) */
17521752
if (ret == WS_SUCCESS)
17531753
ret = GetStringRef(&privSz, &priv, buf, len, idx); /* k || ENC(A) */
1754+
if (ret == WS_SUCCESS)
1755+
if (privSz < pubSz)
1756+
ret = WS_KEY_FORMAT_E;
17541757

17551758
if (ret == WS_SUCCESS)
17561759
ret = wc_ed25519_import_private_key(priv, privSz - pubSz,
@@ -12005,7 +12008,7 @@ static int KeyAgreeEcdh_server(WOLFSSH* ssh, byte hashId, byte* f, word32* fSz)
1200512008
#ifndef WOLFSSH_NO_ECDH
1200612009
{
1200712010
int ret = WS_SUCCESS;
12008-
void* heap;
12011+
void* heap = ssh->ctx->heap;
1200912012
#ifdef WOLFSSH_SMALL_STACK
1201012013
ecc_key *pubKey = NULL, *privKey = NULL;
1201112014
pubKey = (ecc_key*)WMALLOC(sizeof(ecc_key), heap,
@@ -12024,7 +12027,6 @@ static int KeyAgreeEcdh_server(WOLFSSH* ssh, byte hashId, byte* f, word32* fSz)
1202412027
WLOG(WS_LOG_DEBUG, "Entering KeyAgreeEcdh_server()");
1202512028
WOLFSSH_UNUSED(hashId);
1202612029

12027-
heap = ssh->ctx->heap;
1202812030
primeId = wcPrimeForId(ssh->handshake->kexId);
1202912031
if (primeId == ECC_CURVE_INVALID)
1203012032
ret = WS_INVALID_PRIME_CURVE;

0 commit comments

Comments
 (0)