Skip to content

Commit bc06438

Browse files
authored
Merge pull request #6873 from JacobBarthelmeh/coverity
Coverity scan touch up
2 parents 19870b2 + b7b0316 commit bc06438

5 files changed

Lines changed: 38 additions & 23 deletions

File tree

examples/pem/pem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ static int ConvDerToPem(unsigned char* in, word32 offset, word32 len,
628628
type);
629629
if (ret <= 0) {
630630
fprintf(stderr, "Could not convert DER to PEM\n");
631+
free(pem);
631632
}
632633
if (ret > 0) {
633634
*out = pem;

src/crl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,10 @@ int wolfSSL_X509_STORE_add_crl(WOLFSSL_X509_STORE *store, WOLFSSL_X509_CRL *newc
844844
return BAD_MUTEX_E;
845845
}
846846
if (DupX509_CRL(crl, newcrl) != 0) {
847-
if (crl != NULL)
847+
if (crl != NULL) {
848+
wc_UnLockRwLock(&newcrl->crlLock);
848849
FreeCRL(crl, 1);
850+
}
849851
return WOLFSSL_FAILURE;
850852
}
851853
wc_UnLockRwLock(&newcrl->crlLock);

src/ssl.c

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7942,19 +7942,21 @@ int wolfSSL_LoadCRLBuffer(WOLFSSL* ssl, const unsigned char* buff,
79427942
int wolfSSL_EnableOCSP(WOLFSSL* ssl, int options)
79437943
{
79447944
WOLFSSL_ENTER("wolfSSL_EnableOCSP");
7945-
SSL_CM_WARNING(ssl);
7946-
if (ssl)
7945+
if (ssl) {
7946+
SSL_CM_WARNING(ssl);
79477947
return wolfSSL_CertManagerEnableOCSP(SSL_CM(ssl), options);
7948+
}
79487949
else
79497950
return BAD_FUNC_ARG;
79507951
}
79517952

79527953
int wolfSSL_DisableOCSP(WOLFSSL* ssl)
79537954
{
79547955
WOLFSSL_ENTER("wolfSSL_DisableOCSP");
7955-
SSL_CM_WARNING(ssl);
7956-
if (ssl)
7956+
if (ssl) {
7957+
SSL_CM_WARNING(ssl);
79577958
return wolfSSL_CertManagerDisableOCSP(SSL_CM(ssl));
7959+
}
79587960
else
79597961
return BAD_FUNC_ARG;
79607962
}
@@ -7963,29 +7965,32 @@ int wolfSSL_DisableOCSP(WOLFSSL* ssl)
79637965
int wolfSSL_EnableOCSPStapling(WOLFSSL* ssl)
79647966
{
79657967
WOLFSSL_ENTER("wolfSSL_EnableOCSPStapling");
7966-
SSL_CM_WARNING(ssl);
7967-
if (ssl)
7968+
if (ssl) {
7969+
SSL_CM_WARNING(ssl);
79687970
return wolfSSL_CertManagerEnableOCSPStapling(SSL_CM(ssl));
7971+
}
79697972
else
79707973
return BAD_FUNC_ARG;
79717974
}
79727975

79737976
int wolfSSL_DisableOCSPStapling(WOLFSSL* ssl)
79747977
{
79757978
WOLFSSL_ENTER("wolfSSL_DisableOCSPStapling");
7976-
SSL_CM_WARNING(ssl);
7977-
if (ssl)
7979+
if (ssl) {
7980+
SSL_CM_WARNING(ssl);
79787981
return wolfSSL_CertManagerDisableOCSPStapling(SSL_CM(ssl));
7982+
}
79797983
else
79807984
return BAD_FUNC_ARG;
79817985
}
79827986

79837987
int wolfSSL_SetOCSP_OverrideURL(WOLFSSL* ssl, const char* url)
79847988
{
79857989
WOLFSSL_ENTER("wolfSSL_SetOCSP_OverrideURL");
7986-
SSL_CM_WARNING(ssl);
7987-
if (ssl)
7990+
if (ssl) {
7991+
SSL_CM_WARNING(ssl);
79887992
return wolfSSL_CertManagerSetOCSPOverrideURL(SSL_CM(ssl), url);
7993+
}
79897994
else
79907995
return BAD_FUNC_ARG;
79917996
}
@@ -7995,8 +8000,8 @@ int wolfSSL_SetOCSP_Cb(WOLFSSL* ssl,
79958000
CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx)
79968001
{
79978002
WOLFSSL_ENTER("wolfSSL_SetOCSP_Cb");
7998-
SSL_CM_WARNING(ssl);
79998003
if (ssl) {
8004+
SSL_CM_WARNING(ssl);
80008005
ssl->ocspIOCtx = ioCbCtx; /* use SSL specific ioCbCtx */
80018006
return wolfSSL_CertManagerSetOCSP_Cb(SSL_CM(ssl),
80028007
ioCb, respFreeCb, NULL);
@@ -8587,9 +8592,10 @@ int wolfSSL_trust_peer_cert(WOLFSSL* ssl, const char* file, int type)
85878592
int wolfSSL_EnableCRL(WOLFSSL* ssl, int options)
85888593
{
85898594
WOLFSSL_ENTER("wolfSSL_EnableCRL");
8590-
SSL_CM_WARNING(ssl);
8591-
if (ssl)
8595+
if (ssl) {
8596+
SSL_CM_WARNING(ssl);
85928597
return wolfSSL_CertManagerEnableCRL(SSL_CM(ssl), options);
8598+
}
85938599
else
85948600
return BAD_FUNC_ARG;
85958601
}
@@ -8598,9 +8604,10 @@ int wolfSSL_EnableCRL(WOLFSSL* ssl, int options)
85988604
int wolfSSL_DisableCRL(WOLFSSL* ssl)
85998605
{
86008606
WOLFSSL_ENTER("wolfSSL_DisableCRL");
8601-
SSL_CM_WARNING(ssl);
8602-
if (ssl)
8607+
if (ssl) {
8608+
SSL_CM_WARNING(ssl);
86038609
return wolfSSL_CertManagerDisableCRL(SSL_CM(ssl));
8610+
}
86048611
else
86058612
return BAD_FUNC_ARG;
86068613
}
@@ -8609,19 +8616,21 @@ int wolfSSL_DisableCRL(WOLFSSL* ssl)
86098616
int wolfSSL_LoadCRL(WOLFSSL* ssl, const char* path, int type, int monitor)
86108617
{
86118618
WOLFSSL_ENTER("wolfSSL_LoadCRL");
8612-
SSL_CM_WARNING(ssl);
8613-
if (ssl)
8619+
if (ssl) {
8620+
SSL_CM_WARNING(ssl);
86148621
return wolfSSL_CertManagerLoadCRL(SSL_CM(ssl), path, type, monitor);
8622+
}
86158623
else
86168624
return BAD_FUNC_ARG;
86178625
}
86188626

86198627
int wolfSSL_LoadCRLFile(WOLFSSL* ssl, const char* file, int type)
86208628
{
86218629
WOLFSSL_ENTER("wolfSSL_LoadCRLFile");
8622-
SSL_CM_WARNING(ssl);
8623-
if (ssl)
8630+
if (ssl) {
8631+
SSL_CM_WARNING(ssl);
86248632
return wolfSSL_CertManagerLoadCRLFile(SSL_CM(ssl), file, type);
8633+
}
86258634
else
86268635
return BAD_FUNC_ARG;
86278636
}
@@ -8631,9 +8640,10 @@ int wolfSSL_LoadCRLFile(WOLFSSL* ssl, const char* file, int type)
86318640
int wolfSSL_SetCRL_Cb(WOLFSSL* ssl, CbMissingCRL cb)
86328641
{
86338642
WOLFSSL_ENTER("wolfSSL_SetCRL_Cb");
8634-
SSL_CM_WARNING(ssl);
8635-
if (ssl)
8643+
if (ssl) {
8644+
SSL_CM_WARNING(ssl);
86368645
return wolfSSL_CertManagerSetCRL_Cb(SSL_CM(ssl), cb);
8646+
}
86378647
else
86388648
return BAD_FUNC_ARG;
86398649
}

src/ssl_certman.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,8 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
13281328
WOLFSSL_MSG("Cert cache file write failed");
13291329
ret = FWRITE_ERROR;
13301330
}
1331+
}
1332+
if (mem != NULL) {
13311333
XFREE(mem, cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
13321334
}
13331335

wolfcrypt/src/asn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13035,7 +13035,7 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
1303513035
j = 0;
1303613036
/* Append each number of dotted form. */
1303713037
for (i = 0; i < tmpSize; i++) {
13038-
if (j > MAX_OID_SZ) {
13038+
if (j >= MAX_OID_SZ) {
1303913039
return BUFFER_E;
1304013040
}
1304113041

0 commit comments

Comments
 (0)