Skip to content
Open
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
25 changes: 23 additions & 2 deletions libsofia-sip-ua/su/sofia-sip/su_tagarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,28 @@ typedef struct {
*
* @hideinitializer
*/
#if SU_HAVE_TAGSTACK

/* AddressSanitizer instruments the stack so the SU_HAVE_TAGSTACK fast path -
* which reads the variable arguments directly off the caller's stack via
* TAG_NEXT(&(v) + 1) - is walked below the ta stack object when the tag list is
* traversed (t_next -> t_next_next follows the raw stack pointer), which ASan
* correctly reports as a stack-buffer-underflow. Fall back to the portable
* va_list copy path (tl_vlist) under ASan. */
#if defined(__SANITIZE_ADDRESS__)
# define SU_TAGARG_ASAN 1
#elif defined(__has_feature)
# if __has_feature(address_sanitizer)
# define SU_TAGARG_ASAN 1
# endif
#endif

#if SU_HAVE_TAGSTACK && !defined(SU_TAGARG_ASAN)
# define SU_TAGARG_USE_TAGSTACK 1
#else
# define SU_TAGARG_USE_TAGSTACK 0
#endif

#if SU_TAGARG_USE_TAGSTACK
/* All arguments are saved into stack (left-to-right) */
#define ta_start(ta, t, v) \
do { \
Expand Down Expand Up @@ -188,7 +209,7 @@ typedef struct {
*
* @hideinitializer
*/
#if SU_HAVE_TAGSTACK
#if SU_TAGARG_USE_TAGSTACK
#define ta_end(ta) (va_end((ta).ap), (ta).tl->t_tag = NULL)
#else
#define ta_end(ta) \
Expand Down