From 62155df04db540f1205fa1b36c1b9fab1dbc94f7 Mon Sep 17 00:00:00 2001 From: Lev Walkin Date: Sat, 21 Oct 2017 01:16:17 -0700 Subject: [PATCH] add stack overflow protection for SEQUENCE and SEQUENCE OF --- skeletons/constr_SEQUENCE_oer.c | 5 +++-- skeletons/constr_SET.c | 2 +- skeletons/constr_SET_OF.c | 4 ++-- skeletons/constr_SET_OF_oer.c | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/skeletons/constr_SEQUENCE_oer.c b/skeletons/constr_SEQUENCE_oer.c index 6ef1e4df..85310a4d 100644 --- a/skeletons/constr_SEQUENCE_oer.c +++ b/skeletons/constr_SEQUENCE_oer.c @@ -95,10 +95,11 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx; /* Decoder context */ size_t consumed_myself = 0; /* Consumed bytes from ptr. */ - - (void)opt_codec_ctx; (void)constraints; + if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx)) + ASN__DECODE_FAILED; + /* * Create the target structure if it is not present already. */ diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c index 994abb7b..c54b5dee 100644 --- a/skeletons/constr_SET.c +++ b/skeletons/constr_SET.c @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 2003-2017 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c index f3f52942..e6864718 100644 --- a/skeletons/constr_SET_OF.c +++ b/skeletons/constr_SET_OF.c @@ -1,5 +1,5 @@ -/*- - * Copyright (c) 2003, 2004, 2005 Lev Walkin . +/* + * Copyright (c) 2003-2017 Lev Walkin . * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ diff --git a/skeletons/constr_SET_OF_oer.c b/skeletons/constr_SET_OF_oer.c index 1357c2b6..d139fe9c 100644 --- a/skeletons/constr_SET_OF_oer.c +++ b/skeletons/constr_SET_OF_oer.c @@ -117,9 +117,11 @@ SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx; /* Decoder context */ size_t consumed_myself = 0; /* Consumed bytes from ptr. */ - (void)opt_codec_ctx; (void)constraints; + if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx)) + ASN__DECODE_FAILED; + /* * Create the target structure if it is not present already. */