Commit 04d72eb0 authored by Mouse's avatar Mouse

Merge branch 'vlm_master' of https://github.com/mouse07410/asn1c into vlm_master

parents d6e6223b 08b293e8
...@@ -136,8 +136,25 @@ asn__format_to_callback( ...@@ -136,8 +136,25 @@ asn__format_to_callback(
/* /*
* Check stack against overflow, if limit is set. * Check stack against overflow, if limit is set.
*/ */
/* Since GCC 13, AddressSanitizer started defaulting to
* ASAN_OPTIONS="detect_stack_use_after_return=1", which makes this check
* fail due to apparently jumping stack pointers.
* Hence, disable this check if building with ASan, as documented in:
* GCC: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
* Clang: https://clang.llvm.org/docs/AddressSanitizer.html#conditional-compilation-with-has-feature-address-sanitizer
*/
#if defined(__SANITIZE_ADDRESS__)
#define ASN__SANITIZE_ENABLED 1
#elif defined(__has_feature)
#if __has_feature(address_sanitizer)
#define ASN__SANITIZE_ENABLED 1
#endif
#endif
#define ASN__DEFAULT_STACK_MAX (30000) #define ASN__DEFAULT_STACK_MAX (30000)
#ifdef ASN_DISABLE_STACK_OVERFLOW_CHECK
#if defined(ASN__SANITIZE_ENABLED) || defined(ASN_DISABLE_STACK_OVERFLOW_CHECK)
static int CC_NOTUSED static int CC_NOTUSED
ASN__STACK_OVERFLOW_CHECK(const asn_codec_ctx_t *ctx) { ASN__STACK_OVERFLOW_CHECK(const asn_codec_ctx_t *ctx) {
(void)ctx; (void)ctx;
......
...@@ -53,8 +53,8 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx, ...@@ -53,8 +53,8 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(specs->ext_start == -1) if(specs->ext_start == -1)
ASN__DECODE_FAILED; ASN__DECODE_FAILED;
if (ct && ct->upper_bound >= ct->lower_bound) { if(specs && specs->tag2el_count > specs->ext_start) {
value = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound + 1); value = aper_get_nsnnwn(pd, specs->tag2el_count - specs->ext_start); /* extension elements range */
if(value < 0) ASN__DECODE_STARVED; if(value < 0) ASN__DECODE_STARVED;
value += specs->ext_start; value += specs->ext_start;
if((unsigned)value >= td->elements_count) if((unsigned)value >= td->elements_count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment