wolfssl/test.h: revert heap shim refactor -- api.c relies on these being native heap allocations.

pull/8164/head
Daniel Pouzzner 2024-11-08 01:03:44 -06:00
parent aa18bbca55
commit 469b9efc9e
1 changed files with 21 additions and 21 deletions

View File

@ -2257,7 +2257,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
LIBCALL_CHECK_RET(XFSEEK(lFile, 0, XSEEK_SET)); LIBCALL_CHECK_RET(XFSEEK(lFile, 0, XSEEK_SET));
if (fileSz > 0) { if (fileSz > 0) {
*bufLen = (size_t)fileSz; *bufLen = (size_t)fileSz;
*buf = (byte*)XMALLOC(*bufLen, NULL, DYNAMIC_TYPE_TMP_BUFFER); *buf = (byte*)malloc(*bufLen);
if (*buf == NULL) { if (*buf == NULL) {
ret = MEMORY_E; ret = MEMORY_E;
fprintf(stderr, fprintf(stderr,
@ -2322,7 +2322,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
} }
if (buff) if (buff)
XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(buff);
} }
static WC_INLINE void load_ssl_buffer(WOLFSSL* ssl, const char* fname, int type) static WC_INLINE void load_ssl_buffer(WOLFSSL* ssl, const char* fname, int type)
@ -2364,7 +2364,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
} }
if (buff) if (buff)
XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(buff);
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
@ -2378,20 +2378,20 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
if (ret != 0) if (ret != 0)
return ret; return ret;
*derBuf = (byte*)XMALLOC(bufLen, NULL, DYNAMIC_TYPE_TMP_BUFFER); *derBuf = (byte*)malloc(bufLen);
if (*derBuf == NULL) { if (*derBuf == NULL) {
XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(buf);
return MEMORY_E; return MEMORY_E;
} }
ret = wc_KeyPemToDer(buf, (word32)bufLen, *derBuf, (word32)bufLen, NULL); ret = wc_KeyPemToDer(buf, (word32)bufLen, *derBuf, (word32)bufLen, NULL);
if (ret < 0) { if (ret < 0) {
XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(buf);
XFREE(*derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(*derBuf);
return ret; return ret;
} }
*derLen = ret; *derLen = ret;
XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(buf);
return 0; return 0;
} }
@ -3060,14 +3060,14 @@ static WC_INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
AtomicEncCtx* encCtx; AtomicEncCtx* encCtx;
AtomicDecCtx* decCtx; AtomicDecCtx* decCtx;
encCtx = (AtomicEncCtx*)XMALLOC(sizeof(AtomicEncCtx), NULL, DYNAMIC_TYPE_TMP_BUFFER); encCtx = (AtomicEncCtx*)malloc(sizeof(AtomicEncCtx));
if (encCtx == NULL) if (encCtx == NULL)
err_sys_with_errno("AtomicEncCtx malloc failed"); err_sys_with_errno("AtomicEncCtx malloc failed");
XMEMSET(encCtx, 0, sizeof(AtomicEncCtx)); XMEMSET(encCtx, 0, sizeof(AtomicEncCtx));
decCtx = (AtomicDecCtx*)XMALLOC(sizeof(AtomicDecCtx), NULL, DYNAMIC_TYPE_TMP_BUFFER); decCtx = (AtomicDecCtx*)malloc(sizeof(AtomicDecCtx));
if (decCtx == NULL) { if (decCtx == NULL) {
XFREE(encCtx, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(encCtx);
err_sys_with_errno("AtomicDecCtx malloc failed"); err_sys_with_errno("AtomicDecCtx malloc failed");
} }
XMEMSET(decCtx, 0, sizeof(AtomicDecCtx)); XMEMSET(decCtx, 0, sizeof(AtomicDecCtx));
@ -3102,12 +3102,12 @@ static WC_INLINE void FreeAtomicUser(WOLFSSL* ssl)
if (encCtx != NULL) { if (encCtx != NULL) {
if (encCtx->keySetup == 1) if (encCtx->keySetup == 1)
wc_AesFree(&encCtx->aes); wc_AesFree(&encCtx->aes);
XFREE(encCtx, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(encCtx);
} }
if (decCtx != NULL) { if (decCtx != NULL) {
if (decCtx->keySetup == 1) if (decCtx->keySetup == 1)
wc_AesFree(&decCtx->aes); wc_AesFree(&decCtx->aes);
XFREE(decCtx, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(decCtx);
} }
} }
@ -3255,7 +3255,7 @@ static WC_INLINE int myEccSign(WOLFSSL* ssl, const byte* in, word32 inSz,
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK ECC Sign: ret %d outSz %u\n", ret, *outSz); WOLFSSL_PKMSG("PK ECC Sign: ret %d outSz %u\n", ret, *outSz);
@ -3466,7 +3466,7 @@ static WC_INLINE int myEd25519Sign(WOLFSSL* ssl, const byte* in, word32 inSz,
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK 25519 Sign: ret %d, outSz %d\n", ret, *outSz); WOLFSSL_PKMSG("PK 25519 Sign: ret %d, outSz %d\n", ret, *outSz);
@ -3635,7 +3635,7 @@ static WC_INLINE int myEd448Sign(WOLFSSL* ssl, const byte* in, word32 inSz,
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK 448 Sign: ret %d, outSz %u\n", ret, *outSz); WOLFSSL_PKMSG("PK 448 Sign: ret %d, outSz %u\n", ret, *outSz);
@ -3835,7 +3835,7 @@ static WC_INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz,
wc_FreeRng(&rng); wc_FreeRng(&rng);
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK RSA Sign: ret %d, outSz %u\n", ret, *outSz); WOLFSSL_PKMSG("PK RSA Sign: ret %d, outSz %u\n", ret, *outSz);
@ -3898,7 +3898,7 @@ static WC_INLINE int myRsaSignCheck(WOLFSSL* ssl, byte* sig, word32 sigSz,
wc_FreeRsaKey(&myKey); wc_FreeRsaKey(&myKey);
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK RSA SignCheck: ret %d\n", ret); WOLFSSL_PKMSG("PK RSA SignCheck: ret %d\n", ret);
@ -3994,7 +3994,7 @@ static WC_INLINE int myRsaPssSign(WOLFSSL* ssl, const byte* in, word32 inSz,
wc_FreeRng(&rng); wc_FreeRng(&rng);
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK RSA PSS Sign: ret %d, outSz %u\n", ret, *outSz); WOLFSSL_PKMSG("PK RSA PSS Sign: ret %d, outSz %u\n", ret, *outSz);
@ -4102,7 +4102,7 @@ static WC_INLINE int myRsaPssSignCheck(WOLFSSL* ssl, byte* sig, word32 sigSz,
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK RSA PSS SignCheck: ret %d\n", ret); WOLFSSL_PKMSG("PK RSA PSS SignCheck: ret %d\n", ret);
@ -4188,7 +4188,7 @@ static WC_INLINE int myRsaDec(WOLFSSL* ssl, byte* in, word32 inSz,
} }
#ifdef TEST_PK_PRIVKEY #ifdef TEST_PK_PRIVKEY
XFREE(keyBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); free(keyBuf);
#endif #endif
WOLFSSL_PKMSG("PK RSA Dec: ret %d\n", ret); WOLFSSL_PKMSG("PK RSA Dec: ret %d\n", ret);