Skip to content

Commit 746802b

Browse files
Merge pull request #6652 from douzzer/20230724-cppcheck-2v11
20230724-cppcheck-2v11
2 parents c0b4cde + cebb4da commit 746802b

3 files changed

Lines changed: 31 additions & 14 deletions

File tree

src/internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16823,7 +16823,7 @@ int wolfSSL_DtlsUpdateWindow(word16 cur_hi, word32 cur_lo,
1682316823
diff %= DTLS_WORD_BITS;
1682416824

1682516825
if (idx < WOLFSSL_DTLS_WINDOW_WORDS)
16826-
window[idx] |= (1 << diff);
16826+
window[idx] |= (1U << diff);
1682716827
}
1682816828
else {
1682916829
_DtlsUpdateWindowGTSeq(diff + 1, window);

src/ssl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13684,7 +13684,8 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output)
1368413684
#endif
1368513685
if (output->ticketLenAlloc)
1368613686
XFREE(output->ticket, output->heap, DYNAMIC_TYPE_SESSION_TICK);
13687-
output->ticket = tmpTicket;
13687+
output->ticket = tmpTicket; /* cppcheck-suppress autoVariables
13688+
*/
1368813689
output->ticketLenAlloc = PREALLOC_SESSION_TICKET_LEN;
1368913690
output->ticketLen = 0;
1369013691
tmpBufSet = 1;
@@ -13772,6 +13773,10 @@ int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output)
1377213773
#endif /* HAVE_SESSION_TICKET && WOLFSSL_TLS13 */
1377313774
}
1377413775

13776+
/* mollify confused cppcheck nullPointer warning. */
13777+
if (sess == NULL)
13778+
error = WOLFSSL_FAILURE;
13779+
1377513780
if (error == WOLFSSL_SUCCESS) {
1377613781
#if defined(HAVE_SESSION_TICKET) && defined(WOLFSSL_TLS13)
1377713782
error = wolfSSL_DupSessionEx(sess, output, 1,

wolfcrypt/src/asn.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32124,15 +32124,19 @@ static int EccSpecifiedECDomainDecode(const byte* input, word32 inSz,
3212432124
}
3212532125
#ifndef WOLFSSL_NO_ASN_STRICT
3212632126
/* Only version 2 and above can have a seed. */
32127-
if ((ret == 0) && (dataASN[ECCSPECIFIEDASN_IDX_PARAM_SEED].tag != 0) &&
32127+
if (ret == 0) {
32128+
if ((dataASN[ECCSPECIFIEDASN_IDX_PARAM_SEED].tag != 0) &&
3212832129
(version < 2)) {
32129-
ret = ASN_PARSE_E;
32130+
ret = ASN_PARSE_E;
32131+
}
3213032132
}
3213132133
#endif
3213232134
/* Only version 2 and above can have a hash algorithm. */
32133-
if ((ret == 0) && (dataASN[ECCSPECIFIEDASN_IDX_HASH_SEQ].tag != 0) &&
32135+
if (ret == 0) {
32136+
if ((dataASN[ECCSPECIFIEDASN_IDX_HASH_SEQ].tag != 0) &&
3213432137
(version < 2)) {
32135-
ret = ASN_PARSE_E;
32138+
ret = ASN_PARSE_E;
32139+
}
3213632140
}
3213732141
if ((ret == 0) && (dataASN[ECCSPECIFIEDASN_IDX_COFACTOR].tag != 0)) {
3213832142
/* Store optional co-factor. */
@@ -32447,8 +32451,10 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
3244732451
inOutIdx, inSz);
3244832452
}
3244932453
/* Only version 1 supported. */
32450-
if ((ret == 0) && (version != 1)) {
32451-
ret = ASN_PARSE_E;
32454+
if (ret == 0) {
32455+
if (version != 1) {
32456+
ret = ASN_PARSE_E;
32457+
}
3245232458
}
3245332459
/* Curve Parameters are optional. */
3245432460
if ((ret == 0) && (dataASN[ECCKEYASN_IDX_PARAMS].tag != 0)) {
@@ -34416,8 +34422,10 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3441634422
ret = ASN_PARSE_E;
3441734423
}
3441834424
/* Validate the issuer key hash length is the size required. */
34419-
if ((ret == 0) && (issuerKeyHashLen != ocspDigestSize)) {
34420-
ret = ASN_PARSE_E;
34425+
if (ret == 0) {
34426+
if (issuerKeyHashLen != ocspDigestSize) {
34427+
ret = ASN_PARSE_E;
34428+
}
3442134429
}
3442234430
if (ret == 0) {
3442334431
/* Store serial size. */
@@ -34804,12 +34812,16 @@ static int DecodeResponseData(byte* source, word32* ioIndex,
3480434812
1, source, ioIndex, size);
3480534813
}
3480634814
/* Only support v1 == 0 */
34807-
if ((ret == 0) && (version != 0)) {
34808-
ret = ASN_PARSE_E;
34815+
if (ret == 0) {
34816+
if (version != 0) {
34817+
ret = ASN_PARSE_E;
34818+
}
3480934819
}
3481034820
/* Ensure date is a minimal size. */
34811-
if ((ret == 0) && (dateSz < MIN_DATE_SIZE)) {
34812-
ret = ASN_PARSE_E;
34821+
if (ret == 0) {
34822+
if (dateSz < MIN_DATE_SIZE) {
34823+
ret = ASN_PARSE_E;
34824+
}
3481334825
}
3481434826
if (ret == 0) {
3481534827
/* TODO: use byName/byKey fields. */

0 commit comments

Comments
 (0)