diff options
author | Björn Gustavsson <[email protected]> | 2013-02-04 11:06:43 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-02-04 16:25:42 +0100 |
commit | 0fd671609f7b31a9313d1575434e7273f3f2cd09 (patch) | |
tree | ffab0e500bc4aed6cf36aecc25d8987864b954db | |
parent | 10c73156d654bc1ada7afbc3cd7f81b2091057f0 (diff) | |
download | otp-0fd671609f7b31a9313d1575434e7273f3f2cd09.tar.gz otp-0fd671609f7b31a9313d1575434e7273f3f2cd09.tar.bz2 otp-0fd671609f7b31a9313d1575434e7273f3f2cd09.zip |
asn1_erl_nif: Correct broken length encoding
The ber_bin_v2 backend calls a NIF function to decode all tags
and lengths. Even open types that should not be decoded will also be
decoded, which makes it necessary to later re-encode the data using
a NIF function.
The NIF function incorrectly encoded lengths.
-rw-r--r-- | lib/asn1/c_src/asn1_erl_nif.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/asn1/c_src/asn1_erl_nif.c b/lib/asn1/c_src/asn1_erl_nif.c index dbff14f9b3..26803a25a4 100644 --- a/lib/asn1/c_src/asn1_erl_nif.c +++ b/lib/asn1/c_src/asn1_erl_nif.c @@ -1134,8 +1134,8 @@ int ber_encode_length(size_t size, mem_chunk_t **curr, unsigned int *count) { (*curr)->curr -= 1; (*count)++; } else { - int chunks = size / 256 + 1; - if (ber_check_memory(curr, chunks + 1)) + int chunks = 0; + if (ber_check_memory(curr, 8)) return ASN1_ERROR; while (size > 0) @@ -1144,6 +1144,7 @@ int ber_encode_length(size_t size, mem_chunk_t **curr, unsigned int *count) { size >>= 8; (*curr)->curr -= 1; (*count)++; + chunks++; } *(*curr)->curr = chunks | 0x80; |