Skip to content

Commit 710082c

Browse files
committed
Fix uninit variable in KeyAgreeEcdh_server
1 parent a608f19 commit 710082c

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,
@@ -11988,7 +11991,7 @@ static int KeyAgreeEcdh_server(WOLFSSH* ssh, byte hashId, byte* f, word32* fSz)
1198811991
#ifndef WOLFSSH_NO_ECDH
1198911992
{
1199011993
int ret = WS_SUCCESS;
11991-
void* heap;
11994+
void* heap = ssh->ctx->heap;
1199211995
#ifdef WOLFSSH_SMALL_STACK
1199311996
ecc_key *pubKey = NULL, *privKey = NULL;
1199411997
pubKey = (ecc_key*)WMALLOC(sizeof(ecc_key), heap,
@@ -12007,7 +12010,6 @@ static int KeyAgreeEcdh_server(WOLFSSH* ssh, byte hashId, byte* f, word32* fSz)
1200712010
WLOG(WS_LOG_DEBUG, "Entering KeyAgreeEcdh_server()");
1200812011
WOLFSSH_UNUSED(hashId);
1200912012

12010-
heap = ssh->ctx->heap;
1201112013
primeId = wcPrimeForId(ssh->handshake->kexId);
1201212014
if (primeId == ECC_CURVE_INVALID)
1201312015
ret = WS_INVALID_PRIME_CURVE;

0 commit comments

Comments
 (0)