Skip to content

Commit a170624

Browse files
committed
coverity: init dgst variable test_sha3.c
improper use of neg val api.c copy-paste error in test_wolfSSL_PEM_read_bio_ECPKParameters
1 parent dfe0684 commit a170624

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

tests/api.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38948,12 +38948,14 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void)
3894838948
{
3894938949
XFILE file = XBADFILE;
3895038950
const char* fname = "./certs/ecc-key.der";
38951+
long lsz = 0;
3895138952
size_t sz = 0;
3895238953
byte* buf = NULL;
3895338954

3895438955
ExpectTrue((file = XFOPEN(fname, "rb")) != XBADFILE);
3895538956
ExpectTrue(XFSEEK(file, 0, XSEEK_END) == 0);
38956-
ExpectTrue((sz = XFTELL(file)) != 0);
38957+
ExpectTrue((lsz = XFTELL(file)) > 0);
38958+
sz = (size_t)lsz;
3895738959
ExpectTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
3895838960
ExpectNotNull(buf = (byte*)XMALLOC(sz, HEAP_HINT, DYNAMIC_TYPE_FILE));
3895938961
ExpectIntEQ(XFREAD(buf, 1, sz, file), sz);
@@ -52361,6 +52363,7 @@ static int test_wolfSSL_RSA_verify(void)
5236152363
SHA256_CTX c;
5236252364
EVP_PKEY *evpPkey = NULL;
5236352365
EVP_PKEY *evpPubkey = NULL;
52366+
long lsz = 0;
5236452367
size_t sz;
5236552368

5236652369
/* generate hash */
@@ -52372,10 +52375,11 @@ static int test_wolfSSL_RSA_verify(void)
5237252375
wc_Sha256Free((wc_Sha256*)&c);
5237352376
#endif
5237452377

52375-
/* read privete key file */
52378+
/* read private key file */
5237652379
ExpectTrue((fp = XFOPEN(svrKeyFile, "rb")) != XBADFILE);
5237752380
ExpectIntEQ(XFSEEK(fp, 0, XSEEK_END), 0);
52378-
ExpectTrue((sz = XFTELL(fp)) > 0);
52381+
ExpectTrue((lsz = XFTELL(fp)) > 0);
52382+
sz = (size_t)lsz;
5237952383
ExpectIntEQ(XFSEEK(fp, 0, XSEEK_SET), 0);
5238052384
ExpectNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
5238152385
ExpectIntEQ(XFREAD(buf, 1, sz, fp), sz);
@@ -54544,7 +54548,7 @@ static int test_wolfSSL_PEM_read_bio_ECPKParameters(void)
5454454548
ExpectNotNull(bio = BIO_new_mem_buf((unsigned char*)ec_nc_p384,
5454554549
sizeof(ec_nc_p384)));
5454654550
ExpectNotNull(ret = PEM_read_bio_ECPKParameters(bio, &group, NULL, NULL));
54547-
ExpectIntEQ(group == ret, 1);
54551+
ExpectIntEQ(ret == group, 1);
5454854552
ExpectIntEQ(EC_GROUP_get_curve_name(group), NID_secp384r1);
5454954553
BIO_free(bio);
5455054554
bio = NULL;

tests/api/test_digest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ do { \
788788
type dgst_copy; \
789789
word32 flags; \
790790
\
791+
XMEMSET(&dgst, 0, sizeof(dgst)); \
791792
XMEMSET(&dgst_copy, 0, sizeof(dgst_copy)); \
792793
ExpectIntEQ(wc_Init##inst(&dgst, HEAP_HINT, INVALID_DEVID), 0); \
793794
\

0 commit comments

Comments
 (0)