Skip to content

Commit 52c55d5

Browse files
Fix minor issues
1 parent a5eb03c commit 52c55d5

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/internal.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,8 @@ int IdentifyAsn1Key(const byte* in, word32 inSz, int isPrivate, void* heap,
15011501
/* If decode was successful, this is an RSA key. */
15021502
if (ret == 0) {
15031503
key->keyId = ID_SSH_RSA;
1504+
} else {
1505+
wc_FreeRsaKey(&key->ks.rsa.key);
15041506
}
15051507
}
15061508
}
@@ -1533,7 +1535,12 @@ int IdentifyAsn1Key(const byte* in, word32 inSz, int isPrivate, void* heap,
15331535
case ECC_SECP521R1:
15341536
key->keyId = ID_ECDSA_SHA2_NISTP521;
15351537
break;
1538+
default:
1539+
/* Not a supported curve, so free the key */
1540+
wc_ecc_free(&key->ks.ecc.key);
15361541
}
1542+
} else {
1543+
wc_ecc_free(&key->ks.ecc.key);
15371544
}
15381545
}
15391546
}
@@ -1552,11 +1559,14 @@ int IdentifyAsn1Key(const byte* in, word32 inSz, int isPrivate, void* heap,
15521559
ret = wc_Ed25519PublicKeyDecode(in, &idx,
15531560
&key->ks.ed25519.key, inSz);
15541561
}
1555-
}
15561562

1557-
/* If decode was successful, this is a Ed25519 key. */
1558-
if (ret == 0)
1559-
key->keyId = ID_ED25519;
1563+
/* If decode was successful, this is a Ed25519 key. */
1564+
if (ret == 0) {
1565+
key->keyId = ID_ED25519;
1566+
} else {
1567+
wc_ed25519_free(&key->ks.ed25519.key);
1568+
}
1569+
}
15601570
}
15611571
#endif /* WOLFSSH_NO_ED25519 */
15621572

@@ -13047,7 +13057,7 @@ int SendKexDhReply(WOLFSSH* ssh)
1304713057
else if (useEcc) {
1304813058
ret = KeyAgreeEcdh_server(ssh, hashId, f_ptr, &fSz);
1304913059
}
13050-
if (useCurve25519) {
13060+
else if (useCurve25519) {
1305113061
ret = KeyAgreeCurve25519_server(ssh, hashId, f_ptr, &fSz);
1305213062
}
1305313063
else if (useEccMlKem) {

src/wolfsftp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,6 @@ static int SFTP_CreateLongName(WS_SFTPNAME* name)
27752775

27762776
name->lName = (char*)WMALLOC(totalSz + 1, name->heap, DYNTYPE_SFTP);
27772777
if (name->lName == NULL) {
2778-
WFREE(name->lName, name->heap, DYNTYPE_SFTP);
27792778
return WS_MEMORY_E;
27802779
}
27812780
name->lSz = totalSz;
@@ -3985,6 +3984,7 @@ int wolfSSH_SFTP_RecvRead(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
39853984
if (res != NULL) {
39863985
if (wolfSSH_SFTP_CreateStatus(ssh, type, reqId, res, "English", NULL,
39873986
&outSz) != WS_SIZE_ONLY) {
3987+
WFREE(out, ssh->ctx->heap, DYNTYPE_BUFFER);
39883988
return WS_FATAL_ERROR;
39893989
}
39903990
if (outSz > strSz) {
@@ -5280,6 +5280,7 @@ int wolfSSH_SFTP_RecvFSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
52805280
if (ret == WS_SUCCESS) {
52815281
if (SFTP_SetHeader(ssh, reqId, WOLFSSH_FTP_ATTRS, sz, out)
52825282
!= WS_SUCCESS) {
5283+
WFREE(out, ssh->ctx->heap, DYNTYPE_BUFFER);
52835284
return WS_FATAL_ERROR;
52845285
}
52855286
SFTP_SetAttributes(ssh, out + WOLFSSH_SFTP_HEADER, sz, &atr);

0 commit comments

Comments
 (0)