Skip to content

Commit 93430f0

Browse files
authored
coverity fix (#293)
1 parent d02ae73 commit 93430f0

File tree

9 files changed

+11
-12
lines changed

9 files changed

+11
-12
lines changed

src/wp_aes_block.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,6 @@ static int wp_aes_block_update(wp_AesBlockCtx *ctx, unsigned char *out,
507507
(ctx->tls_version == 0)) {
508508
nextBlocks -= AES_BLOCK_SIZE;
509509
}
510-
if (outSize < oLen) {
511-
ok = 0;
512-
}
513510
}
514511
if (ok && (nextBlocks > 0)) {
515512
if (!wp_aes_block_doit(ctx, out, in, nextBlocks)) {

src/wp_des.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,6 @@ static int wp_des3_block_update(wp_Des3BlockCtx *ctx, unsigned char *out,
457457
(ctx->tls_version == 0)) {
458458
nextBlocks -= DES_BLOCK_SIZE;
459459
}
460-
if (outSize < oLen) {
461-
ok = 0;
462-
}
463460
}
464461
if (ok && (nextBlocks > 0)) {
465462
if (!wp_des3_block_doit(ctx, out, in, nextBlocks)) {

src/wp_dh_exch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static wp_DhCtx* wp_dh_dupctx(wp_DhCtx* src)
158158
wp_dh_free(dst->peer);
159159
wp_dh_free(dst->key);
160160
OPENSSL_free(dst);
161+
dst = NULL;
161162
}
162163
}
163164

@@ -369,7 +370,7 @@ static int wp_dh_derive(wp_DhCtx* ctx, unsigned char* secret,
369370
}
370371
}
371372

372-
if ((!done) && ok) {
373+
if ((!done) && ok && (out != NULL)) {
373374
/* DH key exchange derivation using wolfSSL. */
374375
ok = wp_dh_derive_secret(ctx, out, &outLen, maxLen);
375376
}

src/wp_dh_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ static int wp_dh_get_params(wp_Dh* dh, OSSL_PARAM params[])
784784
if (p != NULL) {
785785
/* When buffer is NULL, return the size irrespective of type */
786786
if (p->data == NULL) {
787-
ok = wp_params_set_mp(params, OSSL_PKEY_PARAM_FFC_P, &dh->key.g, 1);
787+
ok = wp_params_set_mp(params, OSSL_PKEY_PARAM_FFC_P, &dh->key.p, 1);
788788
}
789789
/* When buffer is non-NULL, type must be int or uint */
790790
else

src/wp_ecdh_exch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static wp_EcdhCtx* wp_ecdh_dup(wp_EcdhCtx* src)
159159
wp_ecc_free(src->peer);
160160
wp_ecc_free(src->key);
161161
OPENSSL_free(dst);
162+
dst = NULL;
162163
}
163164
}
164165

src/wp_ecx_exch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static wp_EcxCtx* wp_ecx_dupctx(wp_EcxCtx* src)
117117
if (!ok) {
118118
wp_ecx_free(src->key);
119119
OPENSSL_free(dst);
120+
dst = NULL;
120121
}
121122
}
122123

src/wp_kdf_exch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static wp_KdfCtx* wp_kdf_ctx_dup(wp_KdfCtx* src)
134134

135135
if (!ok) {
136136
OPENSSL_free(dst);
137+
dst = NULL;
137138
}
138139
}
139140

src/wp_mac_kmgmt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static int wp_mac_has(const wp_Mac* mac, int selection)
318318
if (mac == NULL) {
319319
ok = 0;
320320
}
321-
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
321+
if (ok && ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)) {
322322
ok &= mac->key != NULL;
323323
}
324324

@@ -387,7 +387,7 @@ static int wp_mac_import(wp_Mac *mac, int selection, const OSSL_PARAM params[])
387387
ok = 0;
388388
}
389389
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES);
390-
if (p != NULL) {
390+
if (ok && (p != NULL)) {
391391
OPENSSL_free(mac->properties);
392392
mac->properties = NULL;
393393
if (!OSSL_PARAM_get_utf8_string(p, &mac->properties, 0)) {
@@ -495,7 +495,7 @@ static int wp_mac_export(wp_Mac *mac, int selection, OSSL_CALLBACK *paramCb,
495495
ok = 0;
496496
}
497497
}
498-
if (ok && !wp_mac_export_priv_key(mac, params, &paramsSz, data, &idx)) {
498+
if (ok && (data != NULL) && !wp_mac_export_priv_key(mac, params, &paramsSz, data, &idx)) {
499499
ok = 0;
500500
}
501501
}

src/wp_mac_sig.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static wp_MacSigCtx* wp_mac_ctx_new(WOLFPROV_CTX* provCtx,
8282
if (propQuery != NULL) {
8383
p = OPENSSL_strdup(propQuery);
8484
if (p == NULL) {
85+
OPENSSL_free(ctx);
8586
ctx = NULL;
8687
ok = 0;
8788
}
@@ -342,7 +343,7 @@ static const OSSL_PARAM *wp_mac_settable_ctx_params(wp_MacSigCtx *ctx,
342343
OSSL_PARAM_int(OSSL_MAC_PARAM_DIGEST_ONESHOT, NULL),
343344
OSSL_PARAM_size_t(OSSL_MAC_PARAM_TLS_DATA_SIZE, NULL),
344345
OSSL_PARAM_END
345-
};
346+
};
346347
return settable_ctx_params;
347348
}
348349

0 commit comments

Comments
 (0)