Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static word32 SizeASNLength(word32 length)
#endif

#ifdef WOLFSSL_ASN_TEMPLATE
#ifdef WOLFSSL_SMALL_STACK
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_ASN_TEMPLATE_STACK_ALLOC)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new build option being introduced.

  1. Make sure its documented at top of asn.c
  2. Please add to .wolfssl_known_macro_extras:
unrecognized macros used:
WOLFSSL_ASN_TEMPLATE_STACK_ALLOC
add well-formed but unknown macros to .wolfssl_known_macro_extras at top of source tree.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [Medium] New build macro WOLFSSL_ASN_TEMPLATE_STACK_ALLOC is undocumented and silently raises stack usage

WOLFSSL_ASN_TEMPLATE_STACK_ALLOC is introduced here but appears nowhere else in the tree (no settings.h documentation, configure option, or comment). When it is defined together with WOLFSSL_SMALL_STACK, the entire ASN template macro family falls through to the #else (stack) branch, so ASNGetData/ASNSetData arrays are declared on the stack via Type name[cnt] instead of being heap-allocated. The macro switch is internally consistent (DECL/ALLOC/CALLOC/FREE all flip together, so there is no decl/alloc/free mismatch and no regression when the macro is undefined). However, the option deliberately re-introduces potentially large stack arrays that WOLFSSL_SMALL_STACK exists to avoid - a non-obvious tradeoff that callers must understand.

Fix: Document WOLFSSL_ASN_TEMPLATE_STACK_ALLOC (settings.h comment block and/or configure/README) including its purpose (CHERI: keep stack-derived capabilities off the heap) and the explicit warning that it increases stack consumption despite WOLFSSL_SMALL_STACK being set.

/* Declare the variable that is the dynamic data for decoding BER data.
*
* @param [in] name Variable name to declare.
Expand Down
Loading
Loading