Skip to content

Commit ebc7e5a

Browse files
clang warning fix and valgrind fixes
1 parent 11d9871 commit ebc7e5a

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

src/we_aes_block.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int we_aes_cbc_encrypt(we_AesBlock* aes, unsigned char *out,
148148
WOLFENGINE_ENTER(WE_LOG_CIPHER, "we_aes_cbc_encrypt");
149149

150150
/* padding is handled by OpenSSL before passed to we_aes_cbc_encrypt */
151-
rc = wc_AesCbcEncrypt(&aes->aes, out, in, len);
151+
rc = wc_AesCbcEncrypt(&aes->aes, out, in, (unsigned int)len);
152152
if (rc != 0) {
153153
WOLFENGINE_ERROR_FUNC(WE_LOG_CIPHER, "wc_AesCbcEncrypt", rc);
154154
ret = 0;
@@ -179,13 +179,13 @@ static int we_aes_cbc_decrypt(we_AesBlock* aes, unsigned char *out,
179179
WOLFENGINE_ENTER(WE_LOG_CIPHER, "we_aes_cbc_decrypt");
180180

181181
/* padding is handled by OpenSSL before passed to we_aes_cbc_decrypt */
182-
rc = wc_AesCbcDecrypt(&aes->aes, out, in, len);
182+
rc = wc_AesCbcDecrypt(&aes->aes, out, in, (unsigned int)len);
183183
if (rc != 0) {
184184
ret = -1;
185185
}
186186

187187
if (ret >= 0) {
188-
ret = len;
188+
ret = (int)len;
189189
}
190190

191191
WOLFENGINE_LEAVE(WE_LOG_CIPHER, "we_aes_cbc_encrypt", ret);

test/test_hkdf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ static int test_hkdf_md(ENGINE *e, const EVP_MD *md, int mode)
9898
unsigned char oKey[128];
9999
unsigned char wKey[128];
100100

101+
memset(oKey, 0, sizeof(oKey));
102+
memset(wKey, 0, sizeof(wKey));
103+
101104
PRINT_MSG("Calc with OpenSSL");
102105
err = test_hkdf_calc(NULL, oKey, sizeof(oKey), md, mode);
103106
if (err == 1) {

test/test_pkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ int test_pkey_dec(EVP_PKEY *pkey, ENGINE *e, unsigned char *msg, size_t msgLen,
259259
size_t len = cipherLen;
260260
unsigned char *buf;
261261

262-
buf = (unsigned char*)OPENSSL_malloc(cipherLen);
262+
buf = (unsigned char*)OPENSSL_zalloc(cipherLen);
263263
if (buf == NULL) {
264264
err = 1;
265265
}

test/test_rsa.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ static int test_rsa_direct(ENGINE *e, const unsigned char *der, size_t derLen,
398398
err = RAND_bytes(buf, sizeof(buf)) == 0;
399399
}
400400
if (err == 0) {
401-
encryptedBuf = (unsigned char*)OPENSSL_malloc(rsaSize);
401+
encryptedBuf = (unsigned char*)OPENSSL_zalloc(rsaSize);
402402
err = encryptedBuf == NULL;
403403
}
404404
if (err == 0) {
405-
decryptedBuf = (unsigned char*)OPENSSL_malloc(rsaSize);
405+
decryptedBuf = (unsigned char*)OPENSSL_zalloc(rsaSize);
406406
err = decryptedBuf == NULL;
407407
}
408408
if (err == 0) {
409-
noPaddingBuf = (unsigned char*)OPENSSL_malloc(rsaSize);
409+
noPaddingBuf = (unsigned char*)OPENSSL_zalloc(rsaSize);
410410
err = noPaddingBuf == NULL;
411411
}
412412
if (err == 0) {
@@ -956,14 +956,14 @@ static int test_rsa_enc_dec(ENGINE *e, const unsigned char *der, size_t derLen,
956956
}
957957
if (err == 0) {
958958
rsaEncLen = RSA_size(rsaKey);
959-
rsaEnc = (unsigned char*)OPENSSL_malloc(rsaEncLen);
959+
rsaEnc = (unsigned char*)OPENSSL_zalloc(rsaEncLen);
960960
err = rsaEnc == NULL;
961961
}
962962
if (err == 0) {
963963
if (padMode == RSA_NO_PADDING) {
964964
bufLen = rsaEncLen;
965965
}
966-
buf = (unsigned char *)OPENSSL_malloc(bufLen);
966+
buf = (unsigned char *)OPENSSL_zalloc(bufLen);
967967
err = buf == NULL;
968968
}
969969
if (err == 0) {

0 commit comments

Comments
 (0)