Skip to content

Commit 1602ed2

Browse files
committed
wolfcrypt/src/asn.c: rearrange check for null cname in EncodeName() to fix false positive -Wnull-dereference.
src/internal.c: suppress -Wnull-dereference locally in ProcessPeerCertParse() to fix false positive.
1 parent 7c7040d commit 1602ed2

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/internal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10613,8 +10613,11 @@ static void AddHandShakeHeader(byte* output, word32 length,
1061310613
if (hs == NULL)
1061410614
return;
1061510615

10616+
PRAGMA_GCC_DIAG_PUSH;
10617+
PRAGMA_GCC("GCC diagnostic ignored \"-Wnull-dereference\"");
1061610618
hs->type = type;
1061710619
c32to24(length, hs->length); /* type and length same for each */
10620+
PRAGMA_GCC_DIAG_POP;
1061810621
#ifdef WOLFSSL_DTLS
1061910622
if (ssl->options.dtls) {
1062010623
DtlsHandShakeHeader* dtls;
@@ -23312,6 +23315,8 @@ int SendChangeCipher(WOLFSSL* ssl)
2331223315

2331323316
/* get output buffer */
2331423317
output = GetOutputBuffer(ssl);
23318+
if (output == NULL)
23319+
return BUFFER_E;
2331523320

2331623321
AddRecordHeader(output, 1, change_cipher_spec, ssl, CUR_ORDER);
2331723322

wolfcrypt/src/asn.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29915,19 +29915,18 @@ static int EncodeName(EncodedName* name, const char* nameStr,
2991529915
ret = BAD_FUNC_ARG;
2991629916
}
2991729917

29918-
#ifdef WOLFSSL_CUSTOM_OID
29919-
if (ret == 0 && type == ASN_CUSTOM_NAME) {
29920-
if (cname == NULL || cname->custom.oidSz == 0) {
29921-
name->used = 0;
29922-
return 0;
29923-
}
29924-
}
29925-
#else
29926-
(void)cname;
29927-
#endif
29928-
29929-
CALLOC_ASNSETDATA(dataASN, rdnASN_Length, ret, NULL);
2993029918
if (ret == 0) {
29919+
#ifdef WOLFSSL_CUSTOM_OID
29920+
if (type == ASN_CUSTOM_NAME) {
29921+
if (cname == NULL || cname->custom.oidSz == 0) {
29922+
name->used = 0;
29923+
return 0;
29924+
}
29925+
}
29926+
#else
29927+
(void)cname;
29928+
#endif
29929+
CALLOC_ASNSETDATA(dataASN, rdnASN_Length, ret, NULL);
2993129930
nameSz = (word32)XSTRLEN(nameStr);
2993229931
/* Copy the RDN encoding template. ASN.1 tag for the name string is set
2993329932
* based on type. */

0 commit comments

Comments
 (0)