diff options
author | Jack Lloyd <[email protected]> | 2017-04-13 14:46:52 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-04-13 14:46:52 -0400 |
commit | 92a888921a877e73951b6c256429bfae0356b22f (patch) | |
tree | df5024aaef4d5f3288d4d18ac7a1a720f040c8dc /src/lib | |
parent | 4737338d1810c3a8934d83a2579c3772afe53768 (diff) | |
parent | cd72f4ac0bfc6ff5ecafb804e6c61c8d2902d6c4 (diff) |
Merge GH #989 Avoid recursion in BER_Decoder::get_next_object
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/asn1/ber_dec.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/asn1/ber_dec.cpp b/src/lib/asn1/ber_dec.cpp index 7b2147600..bf728a8e8 100644 --- a/src/lib/asn1/ber_dec.cpp +++ b/src/lib/asn1/ber_dec.cpp @@ -218,20 +218,25 @@ BER_Object BER_Decoder::get_next_object() return next; } - decode_tag(m_source, next.type_tag, next.class_tag); - if(next.type_tag == NO_OBJECT) - return next; + for(;;) + { + decode_tag(m_source, next.type_tag, next.class_tag); + if(next.type_tag == NO_OBJECT) + return next; - const size_t length = decode_length(m_source); - if(!m_source->check_available(length)) - throw BER_Decoding_Error("Value truncated"); + const size_t length = decode_length(m_source); + if(!m_source->check_available(length)) + throw BER_Decoding_Error("Value truncated"); - next.value.resize(length); - if(m_source->read(next.value.data(), length) != length) - throw BER_Decoding_Error("Value truncated"); + next.value.resize(length); + if(m_source->read(next.value.data(), length) != length) + throw BER_Decoding_Error("Value truncated"); - if(next.type_tag == EOC && next.class_tag == UNIVERSAL) - return get_next_object(); + if(next.type_tag == EOC && next.class_tag == UNIVERSAL) + continue; + else + break; + } return next; } |