Skip to content

Commit d3c80b8

Browse files
g++ build warning fixes
1 parent d917ec6 commit d3c80b8

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

src/internal.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,8 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
768768
}
769769

770770
if (type == BUFTYPE_PRIVKEY && format != WOLFSSH_FORMAT_RAW) {
771-
key_ptr = WMALLOC(sizeof(union wolfSSH_key), heap, dynamicType);
771+
key_ptr = (union wolfSSH_key*)WMALLOC(sizeof(union wolfSSH_key), heap,
772+
dynamicType);
772773
if (key_ptr == NULL) {
773774
WFREE(der, heap, dynamicType);
774775
return WS_MEMORY_E;
@@ -3115,14 +3116,17 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
31153116
}
31163117

31173118
if (ret == WS_SUCCESS) {
3118-
sigKeyBlock_ptr = WMALLOC(sizeof(struct wolfSSH_sigKeyBlock), ssh->ctx->heap, DYNTYPE_PRIVKEY);
3119+
sigKeyBlock_ptr = (struct wolfSSH_sigKeyBlock*)WMALLOC(
3120+
sizeof(struct wolfSSH_sigKeyBlock), ssh->ctx->heap,
3121+
DYNTYPE_PRIVKEY);
31193122
if (sigKeyBlock_ptr == NULL) {
31203123
ret = WS_MEMORY_E;
31213124
}
31223125

31233126
#ifdef WOLFSSH_SMALL_STACK
31243127
#ifndef WOLFSSH_NO_ECDSA
3125-
key_ptr = WMALLOC(sizeof(ecc_key), ssh->ctx->heap, DYNTYPE_PRIVKEY);
3128+
key_ptr = (ecc_key*)WMALLOC(sizeof(ecc_key), ssh->ctx->heap,
3129+
DYNTYPE_PRIVKEY);
31263130
if (key_ptr == NULL) {
31273131
ret = WS_MEMORY_E;
31283132
}
@@ -4061,14 +4065,15 @@ static int DoUserAuthRequestRsa(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
40614065

40624066
if (ret == WS_SUCCESS) {
40634067
#ifdef WOLFSSH_SMALL_STACK
4064-
checkDigest = WMALLOC(MAX_ENCODED_SIG_SZ, ssh->ctx->heap,
4068+
checkDigest = (byte*)WMALLOC(MAX_ENCODED_SIG_SZ, ssh->ctx->heap,
40654069
DYNTYPE_BUFFER);
40664070
if (checkDigest == NULL)
40674071
ret = WS_MEMORY_E;
40684072
#else
40694073
checkDigest = s_checkDigest;
40704074
#endif
4071-
key_ptr = WMALLOC(sizeof(RsaKey), ssh->ctx->heap, DYNTYPE_PUBKEY);
4075+
key_ptr = (RsaKey*)WMALLOC(sizeof(RsaKey), ssh->ctx->heap,
4076+
DYNTYPE_PUBKEY);
40724077
if (key_ptr == NULL)
40734078
ret = WS_MEMORY_E;
40744079
}
@@ -4154,7 +4159,8 @@ static int DoUserAuthRequestRsa(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
41544159
volatile int compare;
41554160
volatile int sizeCompare;
41564161
#ifdef WOLFSSH_SMALL_STACK
4157-
encDigest = WMALLOC(MAX_ENCODED_SIG_SZ, ssh->ctx->heap, DYNTYPE_BUFFER);
4162+
encDigest = (byte*)WMALLOC(MAX_ENCODED_SIG_SZ, ssh->ctx->heap,
4163+
DYNTYPE_BUFFER);
41584164
if (encDigest == NULL)
41594165
ret = WS_MEMORY_E;
41604166
#else
@@ -4222,9 +4228,10 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
42224228

42234229
if (ret == WS_SUCCESS) {
42244230
#ifdef WOLFSSH_SMALL_STACK
4225-
key_ptr = WMALLOC(sizeof(ecc_key), ssh->ctx->heap, DYNTYPE_PUBKEY);
4226-
sig_r_ptr = WMALLOC(sizeof(mp_int), ssh->ctx->heap, DYNTYPE_MPINT);
4227-
sig_s_ptr = WMALLOC(sizeof(mp_int), ssh->ctx->heap, DYNTYPE_MPINT);
4231+
key_ptr = (ecc_key*)WMALLOC(sizeof(ecc_key), ssh->ctx->heap,
4232+
DYNTYPE_PUBKEY);
4233+
sig_r_ptr = (mp_int*)WMALLOC(sizeof(mp_int), ssh->ctx->heap, DYNTYPE_MPINT);
4234+
sig_s_ptr = (mp_int*)WMALLOC(sizeof(mp_int), ssh->ctx->heap, DYNTYPE_MPINT);
42284235
if (key_ptr == NULL || sig_r_ptr == NULL || sig_s_ptr == NULL)
42294236
ret = WS_MEMORY_E;
42304237
#else
@@ -6832,8 +6839,8 @@ int SendKexDhReply(WOLFSSH* ssh)
68326839
#endif
68336840
struct wolfSSH_sigKeyBlockFull *sigKeyBlock_ptr = NULL;
68346841
#ifdef WOLFSSH_SMALL_STACK
6835-
f_ptr = WMALLOC(KEX_F_SIZE, ssh->ctx->heap, DYNTYPE_BUFFER);
6836-
sig_ptr = WMALLOC(KEX_SIG_SIZE, ssh->ctx->heap, DYNTYPE_BUFFER);
6842+
f_ptr = (byte*)WMALLOC(KEX_F_SIZE, ssh->ctx->heap, DYNTYPE_BUFFER);
6843+
sig_ptr = (byte*)WMALLOC(KEX_SIG_SIZE, ssh->ctx->heap, DYNTYPE_BUFFER);
68376844
if (f_ptr == NULL || sig_ptr == NULL)
68386845
ret = WS_MEMORY_E;
68396846
#else
@@ -6851,7 +6858,8 @@ int SendKexDhReply(WOLFSSH* ssh)
68516858
}
68526859
}
68536860

6854-
sigKeyBlock_ptr = WMALLOC(sizeof(struct wolfSSH_sigKeyBlockFull),
6861+
sigKeyBlock_ptr = (struct wolfSSH_sigKeyBlockFull*)WMALLOC(
6862+
sizeof(struct wolfSSH_sigKeyBlockFull),
68556863
ssh->ctx->heap, DYNTYPE_PRIVKEY);
68566864
if (sigKeyBlock_ptr == NULL)
68576865
ret = WS_MEMORY_E;
@@ -7201,7 +7209,7 @@ int SendKexDhReply(WOLFSSH* ssh)
72017209
DhKey privKey;
72027210
word32 ySz = MAX_KEX_KEY_SZ;
72037211
#ifdef WOLFSSH_SMALL_STACK
7204-
y_ptr = WMALLOC(ySz, ssh->ctx->heap, DYNTYPE_PRIVKEY);
7212+
y_ptr = (byte*)WMALLOC(ySz, ssh->ctx->heap, DYNTYPE_PRIVKEY);
72057213
if (y_ptr == NULL)
72067214
ret = WS_MEMORY_E;
72077215
#else
@@ -7383,8 +7391,8 @@ int SendKexDhReply(WOLFSSH* ssh)
73837391
byte rPad;
73847392
byte sPad;
73857393
#ifdef WOLFSSH_SMALL_STACK
7386-
r_ptr = WMALLOC(rSz, ssh->ctx->heap, DYNTYPE_BUFFER);
7387-
s_ptr = WMALLOC(sSz, ssh->ctx->heap, DYNTYPE_BUFFER);
7394+
r_ptr = (byte*)WMALLOC(rSz, ssh->ctx->heap, DYNTYPE_BUFFER);
7395+
s_ptr = (byte*)WMALLOC(sSz, ssh->ctx->heap, DYNTYPE_BUFFER);
73887396
if (r_ptr == NULL || r_ptr == NULL)
73897397
ret = WS_MEMORY_E;
73907398
#else
@@ -8783,7 +8791,7 @@ int SendUserAuthRequest(WOLFSSH* ssh, byte authId, int addSig)
87838791
ret = WS_BAD_ARGUMENT;
87848792

87858793
if (ret == WS_SUCCESS) {
8786-
keySig_ptr = WMALLOC(sizeof(WS_KeySignature),
8794+
keySig_ptr = (WS_KeySignature*)WMALLOC(sizeof(WS_KeySignature),
87878795
ssh->ctx->heap, DYNTYPE_BUFFER);
87888796
if (!keySig_ptr)
87898797
ret = WS_MEMORY_E;

src/ssh.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,8 @@ int wolfSSH_ReadKey_buffer(const byte* in, word32 inSz, int format,
14821482
word32 scratch = 0;
14831483
union wolfSSH_key *key_ptr = NULL;
14841484

1485-
key_ptr = WMALLOC(sizeof(union wolfSSH_key), heap, DYNTYPE_PRIVKEY);
1485+
key_ptr = (union wolfSSH_key*)WMALLOC(sizeof(union wolfSSH_key), heap,
1486+
DYNTYPE_PRIVKEY);
14861487
if (key_ptr == NULL) {
14871488
return WS_MEMORY_E;
14881489
}

0 commit comments

Comments
 (0)