-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
20231128-misc-fixes #7009
20231128-misc-fixes #7009
Conversation
…tatement. wolfcrypt/src/aes.c: add NEED_AES_TABLES gate around AesSetKey_C() implementations (fixes WOLFSSL_KCAPI_AES builds, probably among others). wolfcrypt/src/sp_int.c: add missing casts to clear -Wconversions.
@@ -30149,7 +30149,7 @@ static int set_curves_list(WOLFSSL* ssl, WOLFSSL_CTX *ctx, const char* names) | |||
char name[MAX_CURVE_NAME_SZ]; | |||
byte groups_len = 0; | |||
#ifdef WOLFSSL_SMALL_STACK | |||
void *heap = ssl? ssl->heap : ctx ? ctx->heap : NULL; (void)heap; | |||
void *heap = ssl? ssl->heap : ctx ? ctx->heap : NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added specifically for (#6995). Would like @gojimmypi to comment before undoing the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for asking. Good catch on a recent change.
remove frivolous (void)heap
I realize that it may look frivolous, however none of the usual explicit syntax adjustments would appease the ESP-IDF v5.1 Espressif compiler. I should have put a comment there as such.
If revisiting this particular line, I've been trying not to assign variables with an expression on the same line as declaring them, per a suggestion from @dgarske. I added the (void)heap
as it was least intrusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for connecting those dots. Reviewing types.h
I've already found and fixed several macro implementations of XMALLOC()
that were missing the needed (void)
ings. Once I'm done I think we'll have it covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@douzzer you have a clever solution. Upon reconsideration of just applying the (void)(h), (void)(type)
to everything in XMALLOC
, I thought perhaps we'd have a problem where genuinely unused variables would not be caught. That's not the case, at least not in Visual Studio. This appears to be is working exactly as desired.
I've confirmed even when no code other than the groups = (int*)XMALLOC
is included, the "Warning: unused variable" is properly not shown:
Further, and this is where it is really cool, when the heap
variable is genuinely not used, the intellisense properly detects that, even with your updated XMALLOC
.
Very nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is the way to do it. And for the record, @julek-wolfssl originated the code pattern for us, and I just expanded its coverage. Works a treat.
…ral XMALLOC/XFREE/XREALLOC macros that were missing them. src/quic.c: fix misspelled DYNAMIC_TYPE_TMP_BUFFER.
…everal XMALLOC/XFREE/XREALLOC macros that were missing them.
@JacobBarthelmeh your intuition about the They're all fixed now, and @gojimmypi confirmed clean build on the latest, after replicating the warning on an intermediate commit. |
retest this please. |
…itialized data and resource leak defects around wc_AesInit() and wc_AesFree(): * followup to wolfSSL#7009 "20231128-misc-fixes" and wolfSSL#7011 "Add missing wc_AesInit calls." * adds WC_DEBUG_CIPHER_LIFECYCLE, which embeds asserts in low-level AES implementations for proper usage of wc_AesInit() and wc_AesFree(). * fixes native CMAC, AES-EAX, and AES-XTS implementations to assure resource release. * adds missing wc_AesXtsInit() API, and adds a new wc_AesXtsSetKey_NoInit(). * fixes misspellings in EVP that unconditionally gated out AES-OFB and AES-XTS. * fixes misspellings in EVP that unconditionally gated out AES-CBC and AES-CFB code in wolfSSL_EVP_CIPHER_CTX_cleanup_cipher(). * openssl compat AES low level cipher API has no counterpart to wc_AesFree(), so these compat APIs will now be gated out in configurations where they would otherwise leak memory or file descriptors (WOLFSSL_AFALG, WOLFSSL_DEVCRYPTO, WOLF_CRYPTO_CB, etc.). A new macro, WC_AESFREE_IS_MANDATORY, is defined in wolfcrypt/aes.h to streamline this dependency. * fixes 40 missing EVP_CIPHER_CTX_cleanup()s and 11 wc_AesFree()s in src/ssl.c, src/ssl_crypto.c, tests/api.c, and wolfcrypt/test/test.c.
src/ssl.c
: remove frivolous(void)heap
to clear-Wdeclaration-after-statement
.wolfcrypt/src/aes.c
: addNEED_AES_TABLES
gate aroundAesSetKey_C()
implementations (fixesWOLFSSL_KCAPI_AES
builds, probably among others).wolfcrypt/src/sp_int.c
: add missing casts to clear-Wconversions
.tested with
wolfssl-multi-test.sh ... super-quick-check all-gcc-latest-c99-smallstack benchmark-wolfcrypt-intelasm-sp-asm-all fips-140-3-dev-kcapi fips-140-3-dev-kcapi-opensslextra-build linuxkm-aesni-sp-asm-pie-insmod-no-ec521-no-dh-no-rsa-ksanitize