Fix a couple dead stores.

pull/293/head
John Safranek 2020-10-14 16:44:50 -07:00
parent 91ca3ee43b
commit b9ccb6f4fb
No known key found for this signature in database
GPG Key ID: 8CE817DE0D3CCB4A
1 changed files with 10 additions and 4 deletions

View File

@ -3023,7 +3023,6 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
/* Load in the server's public signing key */ /* Load in the server's public signing key */
sigKeyBlock.useRsa = ssh->handshake->pubKeyId == ID_SSH_RSA; sigKeyBlock.useRsa = ssh->handshake->pubKeyId == ID_SSH_RSA;
ret = WS_INVALID_ALGO_ID;
if (sigKeyBlock.useRsa) { if (sigKeyBlock.useRsa) {
#ifndef NO_RSA #ifndef NO_RSA
byte* e; byte* e;
@ -3062,6 +3061,7 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
ret = WS_RSA_E; ret = WS_RSA_E;
#else #else
(void)tmpIdx; (void)tmpIdx;
ret = WS_INVALID_ALGO_ID;
#endif #endif
} }
else { else {
@ -3109,12 +3109,13 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
else else
ret = WS_ECC_E; ret = WS_ECC_E;
} }
#else
ret = WS_INVALID_ALGO_ID;
#endif #endif
} }
/* Generate and hash in the shared secret */ /* Generate and hash in the shared secret */
if (ret == 0) { if (ret == 0) {
ret = WS_INVALID_ALGO_ID;
if (!ssh->handshake->useEcc) { if (!ssh->handshake->useEcc) {
#ifndef NO_DH #ifndef NO_DH
ret = wc_DhAgree(&ssh->handshake->privKey.dh, ret = wc_DhAgree(&ssh->handshake->privKey.dh,
@ -3123,6 +3124,8 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
f, fSz); f, fSz);
ForceZero(ssh->handshake->x, ssh->handshake->xSz); ForceZero(ssh->handshake->x, ssh->handshake->xSz);
wc_FreeDhKey(&ssh->handshake->privKey.dh); wc_FreeDhKey(&ssh->handshake->privKey.dh);
#else
ret = WS_INVALID_ALGO_ID;
#endif #endif
} }
else { else {
@ -3140,6 +3143,8 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
&key, ssh->k, &ssh->kSz); &key, ssh->k, &ssh->kSz);
wc_ecc_free(&key); wc_ecc_free(&key);
wc_ecc_free(&ssh->handshake->privKey.ecc); wc_ecc_free(&ssh->handshake->privKey.ecc);
#else
ret = WS_INVALID_ALGO_ID;
#endif #endif
} }
} }
@ -6142,7 +6147,6 @@ static int BundlePacket(WOLFSSH* ssh)
} }
else { else {
if (ret == WS_SUCCESS) { if (ret == WS_SUCCESS) {
ret = WS_INVALID_ALGO_ID;
#ifndef WOLFSSH_NO_AEAD #ifndef WOLFSSH_NO_AEAD
idx += paddingSz; idx += paddingSz;
ret = EncryptAead(ssh, ret = EncryptAead(ssh,
@ -6158,6 +6162,8 @@ static int BundlePacket(WOLFSSH* ssh)
ssh->packetStartIdx, ssh->packetStartIdx,
LENGTH_SZ); LENGTH_SZ);
idx += ssh->macSz; idx += ssh->macSz;
#else
ret = WS_INVALID_ALGO_ID;
#endif #endif
} }
} }