Skip to content

Commit dbfebea

Browse files
authored
Merge pull request #7956 from douzzer/20240906-errcode-fixups
20240906-errcode-fixups
2 parents 398f8c9 + c81c9be commit dbfebea

36 files changed

Lines changed: 551 additions & 545 deletions

src/bio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,13 +1849,13 @@ int wolfSSL_BIO_seek(WOLFSSL_BIO *bio, int ofs)
18491849
WOLFSSL_ENTER("wolfSSL_BIO_seek");
18501850

18511851
if (bio == NULL) {
1852-
return -1;
1852+
return WOLFSSL_FATAL_ERROR;
18531853
}
18541854

18551855
/* offset ofs from beginning of file */
18561856
if (bio->type == WOLFSSL_BIO_FILE &&
18571857
XFSEEK(bio->ptr.fh, ofs, SEEK_SET) < 0) {
1858-
return -1;
1858+
return WOLFSSL_FATAL_ERROR;
18591859
}
18601860

18611861
return 0;
@@ -1872,7 +1872,7 @@ int wolfSSL_BIO_tell(WOLFSSL_BIO* bio)
18721872
WOLFSSL_ENTER("wolfSSL_BIO_tell");
18731873

18741874
if (bio == NULL) {
1875-
return -1;
1875+
return WOLFSSL_FATAL_ERROR;
18761876
}
18771877

18781878
if (bio->type != WOLFSSL_BIO_FILE) {
@@ -1881,7 +1881,7 @@ int wolfSSL_BIO_tell(WOLFSSL_BIO* bio)
18811881

18821882
pos = (int)XFTELL(bio->ptr.fh);
18831883
if (pos < 0)
1884-
return -1;
1884+
return WOLFSSL_FATAL_ERROR;
18851885
else
18861886
return pos;
18871887
}
@@ -3246,7 +3246,7 @@ int wolfSSL_BIO_vprintf(WOLFSSL_BIO* bio, const char* format, va_list args)
32463246
#if !defined(NO_FILESYSTEM)
32473247
case WOLFSSL_BIO_FILE:
32483248
if (bio->ptr.fh == XBADFILE) {
3249-
return -1;
3249+
return WOLFSSL_FATAL_ERROR;
32503250
}
32513251
ret = XVFPRINTF(bio->ptr.fh, format, args);
32523252
break;

src/crl.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
121121
wolfSSL_d2i_X509_NAME(&crle->issuer, (unsigned char**)&dcrl->issuer,
122122
dcrl->issuerSz);
123123
if (crle->issuer == NULL) {
124-
return -1;
124+
return WOLFSSL_FATAL_ERROR;
125125
}
126126
#endif
127127
#ifdef CRL_STATIC_REVOKED_LIST
@@ -141,13 +141,13 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
141141
crle->toBeSigned = (byte*)XMALLOC(crle->tbsSz, heap,
142142
DYNAMIC_TYPE_CRL_ENTRY);
143143
if (crle->toBeSigned == NULL)
144-
return -1;
144+
return WOLFSSL_FATAL_ERROR;
145145
crle->signature = (byte*)XMALLOC(crle->signatureSz, heap,
146146
DYNAMIC_TYPE_CRL_ENTRY);
147147
if (crle->signature == NULL) {
148148
XFREE(crle->toBeSigned, heap, DYNAMIC_TYPE_CRL_ENTRY);
149149
crle->toBeSigned = NULL;
150-
return -1;
150+
return WOLFSSL_FATAL_ERROR;
151151
}
152152

153153
#ifdef WC_RSA_PSS
@@ -160,7 +160,7 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
160160
crle->toBeSigned = NULL;
161161
XFREE(crle->signature, heap, DYNAMIC_TYPE_CRL_ENTRY);
162162
crle->signature = NULL;
163-
return -1;
163+
return WOLFSSL_FATAL_ERROR;
164164
}
165165
XMEMCPY(crle->sigParams, buff + dcrl->sigParamsIndex,
166166
crle->sigParamsSz);
@@ -563,7 +563,7 @@ static int AddCRL(WOLFSSL_CRL* crl, DecodedCRL* dcrl, const byte* buff,
563563
WOLFSSL_ENTER("AddCRL");
564564

565565
if (crl == NULL)
566-
return -1;
566+
return WOLFSSL_FATAL_ERROR;
567567

568568
crle = crl->currentEntry;
569569

@@ -578,7 +578,7 @@ static int AddCRL(WOLFSSL_CRL* crl, DecodedCRL* dcrl, const byte* buff,
578578
if (InitCRL_Entry(crle, dcrl, buff, verified, crl->heap) < 0) {
579579
WOLFSSL_MSG("Init CRL Entry failed");
580580
CRL_Entry_free(crle, crl->heap);
581-
return -1;
581+
return WOLFSSL_FATAL_ERROR;
582582
}
583583

584584
if (wc_LockRwLock_Wr(&crl->crlLock) != 0) {
@@ -625,7 +625,7 @@ int BufferLoadCRL(WOLFSSL_CRL* crl, const byte* buff, long sz, int type,
625625
else {
626626
WOLFSSL_MSG("Pem to Der failed");
627627
FreeDer(&der);
628-
return -1;
628+
return WOLFSSL_FATAL_ERROR;
629629
}
630630
#else
631631
ret = NOT_COMPILED_IN;
@@ -1018,7 +1018,7 @@ static int SwapLists(WOLFSSL_CRL* crl)
10181018
#ifdef WOLFSSL_SMALL_STACK
10191019
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
10201020
#endif
1021-
return -1;
1021+
return WOLFSSL_FATAL_ERROR;
10221022
}
10231023

10241024
if (crl->monitors[0].path) {
@@ -1029,7 +1029,7 @@ static int SwapLists(WOLFSSL_CRL* crl)
10291029
#ifdef WOLFSSL_SMALL_STACK
10301030
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
10311031
#endif
1032-
return -1;
1032+
return WOLFSSL_FATAL_ERROR;
10331033
}
10341034
}
10351035

@@ -1041,7 +1041,7 @@ static int SwapLists(WOLFSSL_CRL* crl)
10411041
#ifdef WOLFSSL_SMALL_STACK
10421042
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
10431043
#endif
1044-
return -1;
1044+
return WOLFSSL_FATAL_ERROR;
10451045
}
10461046
}
10471047

@@ -1051,7 +1051,7 @@ static int SwapLists(WOLFSSL_CRL* crl)
10511051
#ifdef WOLFSSL_SMALL_STACK
10521052
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
10531053
#endif
1054-
return -1;
1054+
return WOLFSSL_FATAL_ERROR;
10551055
}
10561056

10571057
newList = tmp->crlList;
@@ -1103,7 +1103,7 @@ static int StopMonitor(wolfSSL_CRL_mfd_t mfd)
11031103
EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
11041104
if (kevent(mfd, &change, 1, NULL, 0, NULL) < 0) {
11051105
WOLFSSL_MSG("kevent trigger customer event failed");
1106-
return -1;
1106+
return WOLFSSL_FATAL_ERROR;
11071107
}
11081108

11091109
return 0;
@@ -1235,7 +1235,7 @@ static int StopMonitor(wolfSSL_CRL_mfd_t mfd)
12351235
/* write to our custom event */
12361236
if (write(mfd, &w64, sizeof(w64)) < 0) {
12371237
WOLFSSL_MSG("StopMonitor write failed");
1238-
return -1;
1238+
return WOLFSSL_FATAL_ERROR;
12391239
}
12401240

12411241
return 0;
@@ -1378,7 +1378,7 @@ static int StopMonitor(wolfSSL_CRL_mfd_t mfd)
13781378
{
13791379
if (SetEvent(mfd) == 0) {
13801380
WOLFSSL_MSG("SetEvent custom event trigger failed");
1381-
return -1;
1381+
return WOLFSSL_FATAL_ERROR;
13821382
}
13831383
return 0;
13841384
}

src/dtls13.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ int Dtls13RtxTimeout(WOLFSSL* ssl)
25852585

25862586
/* Increase timeout on long timeout */
25872587
if (DtlsMsgPoolTimeout(ssl) != 0)
2588-
return -1;
2588+
return WOLFSSL_FATAL_ERROR;
25892589

25902590
return Dtls13RtxSendBuffered(ssl);
25912591
}

src/internal.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ int wolfSSL_session_export_internal(WOLFSSL* ssl, byte* buf, word32* sz,
21082108
if (type == WOLFSSL_EXPORT_TLS) {
21092109
*sz += AES_BLOCK_SIZE*2;
21102110
}
2111-
ret = LENGTH_ONLY_E;
2111+
ret = WC_NO_ERR_TRACE(LENGTH_ONLY_E);
21122112
}
21132113

21142114
if (ret == 0) {
@@ -10467,7 +10467,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1046710467

1046810468
if (ssl->CBIORecv == NULL) {
1046910469
WOLFSSL_MSG("Your IO Recv callback is null, please set");
10470-
return -1;
10470+
return WOLFSSL_FATAL_ERROR;
1047110471
}
1047210472

1047310473
retry:
@@ -10486,7 +10486,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1048610486
}
1048710487
#endif
1048810488
#endif
10489-
return -1;
10489+
return WOLFSSL_FATAL_ERROR;
1049010490

1049110491
case WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_WANT_READ):
1049210492
if (retryLimit > 0 && ssl->ctx->autoRetry &&
@@ -10503,7 +10503,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1050310503
}
1050410504
#endif
1050510505
ssl->options.connReset = 1;
10506-
return -1;
10506+
return WOLFSSL_FATAL_ERROR;
1050710507

1050810508
case WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_ISR): /* interrupt */
1050910509
/* see if we got our timeout */
@@ -10527,7 +10527,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1052710527

1052810528
case WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_CONN_CLOSE):
1052910529
ssl->options.isClosed = 1;
10530-
return -1;
10530+
return WOLFSSL_FATAL_ERROR;
1053110531

1053210532
case WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_TIMEOUT):
1053310533
#ifdef WOLFSSL_DTLS
@@ -10537,7 +10537,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1053710537
if (Dtls13RtxTimeout(ssl) < 0) {
1053810538
WOLFSSL_MSG(
1053910539
"Error trying to retransmit DTLS buffered message");
10540-
return -1;
10540+
return WOLFSSL_FATAL_ERROR;
1054110541
}
1054210542
goto retry;
1054310543
}
@@ -10552,7 +10552,7 @@ static int wolfSSLReceive(WOLFSSL* ssl, byte* buf, word32 sz)
1055210552
goto retry;
1055310553
}
1055410554
#endif
10555-
return -1;
10555+
return WOLFSSL_FATAL_ERROR;
1055610556

1055710557
default:
1055810558
WOLFSSL_MSG("Unexpected recv return code");
@@ -27580,7 +27580,7 @@ static int CmpEccStrength(int hashAlgo, int curveSz)
2758027580
{
2758127581
int dgstSz = GetMacDigestSize((byte)hashAlgo);
2758227582
if (dgstSz <= 0)
27583-
return -1;
27583+
return WOLFSSL_FATAL_ERROR;
2758427584
return dgstSz - (curveSz & (~0x3));
2758527585
}
2758627586
#endif
@@ -38207,7 +38207,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3820738207
diff -= ticketSeen;
3820838208
if (diff > timeout * 1000 ||
3820938209
diff > (sword64)TLS13_MAX_TICKET_AGE * 1000)
38210-
return -1;
38210+
return WOLFSSL_FATAL_ERROR;
3821138211
#else
3821238212
sword64 diff;
3821338213
sword64 ticketSeen; /* Time ticket seen (ms) */
@@ -38225,7 +38225,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3822538225
diff -= ticketSeen;
3822638226
if (diff > timeout * 1000 ||
3822738227
diff > (sword64)TLS13_MAX_TICKET_AGE * 1000)
38228-
return -1;
38228+
return WOLFSSL_FATAL_ERROR;
3822938229
#endif
3823038230
ato32(psk->it->ageAdd, &ticketAdd);
3823138231
/* Subtract client's ticket age and unobfuscate. */
@@ -38235,26 +38235,26 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3823538235
* Allow +/- 1000 milliseconds on ticket age.
3823638236
*/
3823738237
if (diff < -1000 || diff - MAX_TICKET_AGE_DIFF * 1000 > 1000)
38238-
return -1;
38238+
return WOLFSSL_FATAL_ERROR;
3823938239

3824038240
#if !defined(WOLFSSL_PSK_ONE_ID) && !defined(WOLFSSL_PRIORITIZE_PSK)
3824138241
/* Check whether resumption is possible based on suites in SSL and
3824238242
* ciphersuite in ticket.
3824338243
*/
3824438244
(void)ssl;
3824538245
if (XMEMCMP(suite, psk->it->suite, SUITE_LEN) != 0)
38246-
return -1;
38246+
return WOLFSSL_FATAL_ERROR;
3824738247
#else
3824838248
(void)suite;
3824938249
if (!FindSuiteSSL(ssl, psk->it->suite))
38250-
return -1;
38250+
return WOLFSSL_FATAL_ERROR;
3825138251
#endif
3825238252
#ifdef OPENSSL_EXTRA
3825338253
if (ssl->sessionCtxSz > 0 &&
3825438254
(psk->it->sessionCtxSz != ssl->sessionCtxSz ||
3825538255
XMEMCMP(psk->it->sessionCtx, ssl->sessionCtx,
3825638256
ssl->sessionCtxSz) != 0))
38257-
return -1;
38257+
return WOLFSSL_FATAL_ERROR;
3825838258
#endif
3825938259
return 0;
3826038260
}
@@ -41086,15 +41086,15 @@ int wolfSSL_sk_BY_DIR_HASH_find(
4108641086
}
4108741087
next = next->next;
4108841088
}
41089-
return -1;
41089+
return WOLFSSL_FATAL_ERROR;
4109041090
}
4109141091
/* return a number of WOLFSSL_BY_DIR_HASH in stack */
4109241092
int wolfSSL_sk_BY_DIR_HASH_num(const WOLF_STACK_OF(WOLFSSL_BY_DIR_HASH) *sk)
4109341093
{
4109441094
WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_HASH_num");
4109541095

4109641096
if (sk == NULL)
41097-
return -1;
41097+
return WOLFSSL_FATAL_ERROR;
4109841098
return (int)sk->num;
4109941099
}
4110041100
/* return WOLFSSL_BY_DIR_HASH instance at i */
@@ -41277,7 +41277,7 @@ int wolfSSL_sk_BY_DIR_entry_num(const WOLF_STACK_OF(WOLFSSL_BY_DIR_entry) *sk)
4127741277
WOLFSSL_ENTER("wolfSSL_sk_BY_DIR_entry_num");
4127841278

4127941279
if (sk == NULL)
41280-
return -1;
41280+
return WOLFSSL_FATAL_ERROR;
4128141281
return (int)sk->num;
4128241282
}
4128341283
/* return WOLFSSL_BY_DIR_entry instance at i */

src/ocsp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ int wolfSSL_OCSP_REQ_CTX_nbio(WOLFSSL_OCSP_REQ_CTX *ctx)
16411641
reqLen - ctx->sent);
16421642
if (sent <= 0) {
16431643
if (wolfSSL_BIO_should_retry(ctx->bio))
1644-
return -1;
1644+
return WOLFSSL_FATAL_ERROR;
16451645
WOLFSSL_MSG("wolfSSL_BIO_write error");
16461646
ctx->ioState = ORIOS_INVALID;
16471647
return 0;
@@ -1670,7 +1670,7 @@ int wolfSSL_OCSP_REQ_CTX_nbio(WOLFSSL_OCSP_REQ_CTX *ctx)
16701670
if (ret == WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_WANT_READ) ||
16711671
ret == WC_NO_ERR_TRACE(OCSP_WANT_READ))
16721672
{
1673-
return -1;
1673+
return WOLFSSL_FATAL_ERROR;
16741674
}
16751675
return WOLFSSL_FAILURE;
16761676
}
@@ -1898,7 +1898,7 @@ int wolfSSL_OCSP_check_nonce(OcspRequest* req, WOLFSSL_OCSP_BASICRESP* bs)
18981898

18991899
/* nonce present in req only */
19001900
if (reqNonce != NULL && rspNonce == NULL)
1901-
return -1;
1901+
return WOLFSSL_FATAL_ERROR;
19021902

19031903
/* nonces are present and equal, return 1. Extra NULL check for fixing
19041904
scan-build warning. */

0 commit comments

Comments
 (0)