Skip to content

Commit

Permalink
backfill more missing WC_NO_ERR_TRACE()s on error code operands, and …
Browse files Browse the repository at this point in the history
…refactor away the obsolete GEN_MEM_ERR macro mechanism in wolfcrypt/src/ecc.c.
  • Loading branch information
douzzer committed Sep 3, 2024
1 parent 4d837e7 commit 806df85
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 166 deletions.
10 changes: 5 additions & 5 deletions linuxkm/lkcapi_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ static int aes_xts_128_test(void)
}

#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(SYSLIB_FAILED_E);
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
ret = wc_AesXtsEncrypt(aes, buf, p2, sizeof(p2), i2, sizeof(i2));
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
if (ret != 0)
Expand Down Expand Up @@ -2068,7 +2068,7 @@ static int aes_xts_128_test(void)
}

#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(SYSLIB_FAILED_E);
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
if (ret != 0)
Expand All @@ -2090,7 +2090,7 @@ static int aes_xts_128_test(void)
}

#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(SYSLIB_FAILED_E);
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
XMEMSET(cipher, 0, AES_XTS_128_TEST_BUF_SIZ);
ret = wc_AesXtsEncrypt(aes, cipher, pp, sizeof(pp), i1, sizeof(i1));
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
Expand All @@ -2116,7 +2116,7 @@ static int aes_xts_128_test(void)
}

#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(SYSLIB_FAILED_E);
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
ret = wc_AesXtsDecrypt(aes, buf, cipher, sizeof(pp), i1, sizeof(i1));
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
Expand All @@ -2139,7 +2139,7 @@ static int aes_xts_128_test(void)
}

#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(SYSLIB_FAILED_E);
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
Expand Down
5 changes: 3 additions & 2 deletions src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
}
}
else {
if (Base64_Encode((const byte*)data, inLen, NULL, &sz) !=
LENGTH_ONLY_E) {
if (Base64_Encode((const byte*)data, inLen, NULL, &sz)
!= WC_NO_ERR_TRACE(LENGTH_ONLY_E))
{
WOLFSSL_MSG("Error with base64 get length");
return WOLFSSL_FATAL_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -40363,7 +40363,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],

lenErrMask = 0 - (SECRET_LEN != args->sigSz);
args->lastErr = (ret & (~lenErrMask)) |
(RSA_PAD_E & lenErrMask);
(WC_NO_ERR_TRACE(RSA_PAD_E) & lenErrMask);
ret = 0;
break;
} /* rsa_kea */
Expand Down
2 changes: 1 addition & 1 deletion src/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void wolfSSL_OCSP_BASICRESP_free(WOLFSSL_OCSP_BASICRESP* basicResponse)
int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
WOLF_STACK_OF(WOLFSSL_X509) *certs, WOLFSSL_X509_STORE *st, unsigned long flags)
{
int ret = WOLFSSL_FAILURE;
int ret = WC_NO_ERR_TRACE(WOLFSSL_FAILURE);
#ifdef WOLFSSL_SMALL_STACK
DecodedCert *cert;
#else
Expand Down
18 changes: 10 additions & 8 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2881,8 +2881,9 @@ static int wolfSSL_read_internal(WOLFSSL* ssl, void* data, int sz, int peek)
/* make sure bidirectional TLS shutdown completes */
if (ssl->error == WOLFSSL_ERROR_SYSCALL || ssl->options.shutdownDone) {
/* ask the underlying transport the connection is closed */
if (ssl->CBIORecv(ssl, (char*)data, 0, ssl->IOCB_ReadCtx) ==
WOLFSSL_CBIO_ERR_CONN_CLOSE) {
if (ssl->CBIORecv(ssl, (char*)data, 0, ssl->IOCB_ReadCtx)
== WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_CONN_CLOSE))
{
ssl->options.isClosed = 1;
ssl->error = WOLFSSL_ERROR_ZERO_RETURN;
}
Expand Down Expand Up @@ -3400,7 +3401,7 @@ int wolfSSL_UseALPN(WOLFSSL* ssl, char *protocol_name_list,
char *list, *ptr, **token;
word16 len;
int idx = 0;
int ret = WOLFSSL_FAILURE;
int ret = WC_NO_ERR_TRACE(WOLFSSL_FAILURE);

WOLFSSL_ENTER("wolfSSL_UseALPN");

Expand Down Expand Up @@ -6209,7 +6210,7 @@ static int check_cert_key(DerBuffer* cert, DerBuffer* key, DerBuffer* altKey,
#endif
word32 size;
byte* buff;
int ret = WOLFSSL_FAILURE;
int ret = WC_NO_ERR_TRACE(WOLFSSL_FAILURE);

WOLFSSL_ENTER("check_cert_key");

Expand Down Expand Up @@ -10466,7 +10467,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
static int wolfSSL_ex_wrapper(WOLFSSL* ssl, HandShakeCallBack hsCb,
TimeoutCallBack toCb, WOLFSSL_TIMEVAL timeout)
{
int ret = WOLFSSL_FATAL_ERROR;
int ret = WC_NO_ERR_TRACE(WOLFSSL_FATAL_ERROR);
int oldTimerOn = 0; /* was timer already on */
WOLFSSL_TIMEVAL startTime;
WOLFSSL_TIMEVAL endTime;
Expand Down Expand Up @@ -12190,8 +12191,9 @@ int wolfSSL_get_peer_tmp_key(const WOLFSSL* ssl, WOLFSSL_EVP_PKEY** pkey)
int sz;

PRIVATE_KEY_UNLOCK();
if (wc_ecc_export_x963(ssl->peerEccKey, NULL, &derSz) !=
LENGTH_ONLY_E) {
if (wc_ecc_export_x963(ssl->peerEccKey, NULL, &derSz)
!= WC_NO_ERR_TRACE(LENGTH_ONLY_E))
{
WOLFSSL_MSG("get ecc der size failed");
PRIVATE_KEY_LOCK();
return WOLFSSL_FAILURE;
Expand Down Expand Up @@ -15481,7 +15483,7 @@ int wolfSSL_ERR_GET_REASON(unsigned long err)
/* Nginx looks for this error to know to stop parsing certificates.
* Same for HAProxy. */
if (err == ((ERR_LIB_PEM << 24) | PEM_R_NO_START_LINE) ||
((err & 0xFFFFFFL) == -ASN_NO_PEM_HEADER) ||
((err & 0xFFFFFFL) == -WC_NO_ERR_TRACE(ASN_NO_PEM_HEADER)) ||
((err & 0xFFFL) == PEM_R_NO_START_LINE ))
return PEM_R_NO_START_LINE;
if (err == ((ERR_LIB_SSL << 24) | -SSL_R_HTTP_REQUEST))
Expand Down
2 changes: 1 addition & 1 deletion src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ static int TLSX_ALPN_ParseAndSet(WOLFSSL *ssl, const byte *input, word16 length,
byte isRequest)
{
word16 size = 0, offset = 0, wlen;
int r = BUFFER_ERROR;
int r = WC_NO_ERR_TRACE(BUFFER_ERROR);
const byte *s;

if (OPAQUE16_LEN > length)
Expand Down
2 changes: 1 addition & 1 deletion src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -7073,7 +7073,7 @@ int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup,
{
#if !defined(NO_FILESYSTEM) && \
(defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM))
int ret = WOLFSSL_FAILURE;
int ret = WC_NO_ERR_TRACE(WOLFSSL_FAILURE);
XFILE fp;
long sz;
byte* pem = NULL;
Expand Down
Loading

0 comments on commit 806df85

Please sign in to comment.