diff options
author | Björn Gustavsson <[email protected]> | 2014-06-25 12:45:48 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-08-11 12:58:06 +0200 |
commit | 7f385ebd984ed2931daa761819816b3e9da7d63c (patch) | |
tree | fb5861886ef717b5a4569df1c0d26c9d2dfec56e /lib/asn1/test | |
parent | 2390a7c7e26a7d21b8717efd900f88dae571dc3b (diff) | |
download | otp-7f385ebd984ed2931daa761819816b3e9da7d63c.tar.gz otp-7f385ebd984ed2931daa761819816b3e9da7d63c.tar.bz2 otp-7f385ebd984ed2931daa761819816b3e9da7d63c.zip |
BER decoding: Improve error checking for indefinite length
When an indefinite length was given, the decoder could look beyond
the end of the buffer for the 0,0 that signals the end of the value.
Diffstat (limited to 'lib/asn1/test')
-rw-r--r-- | lib/asn1/test/ber_decode_error.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/asn1/test/ber_decode_error.erl b/lib/asn1/test/ber_decode_error.erl index 8be92292ee..6fd2450c62 100644 --- a/lib/asn1/test/ber_decode_error.erl +++ b/lib/asn1/test/ber_decode_error.erl @@ -51,4 +51,18 @@ run([]) -> {error,{asn1,{invalid_value,_}}} = (catch 'Constructed':decode('I', <<8,7>>)), + %% Short indefinite length. Make sure that the decoder doesn't look + %% beyond the end of binary when looking for a 0,0 terminator. + {error,{asn1,{invalid_length,_}}} = + (catch 'Constructed':decode('S', sub(<<8,16#80,0,0>>, 3))), + {error,{asn1,{invalid_length,_}}} = + (catch 'Constructed':decode('S', sub(<<8,16#80,0,0>>, 2))), + {error,{asn1,{invalid_length,_}}} = + (catch 'Constructed':decode('S', sub(<<40,16#80,1,1,255,0,0>>, 6))), + {error,{asn1,{invalid_length,_}}} = + (catch 'Constructed':decode('S', sub(<<40,16#80,1,1,255,0,0>>, 5))), ok. + +sub(Bin, Bytes) -> + <<B:Bytes/binary,_/binary>> = Bin, + B. |