aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/c_src/asn1_erl_nif.c
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2013-02-06 14:47:12 +0100
committerErlang/OTP <[email protected]>2013-02-06 14:47:12 +0100
commita30a45e158978a6bc13684505f10d5e3824ee819 (patch)
treebd07c843b963495026af782b4aad284bed628d9a /lib/asn1/c_src/asn1_erl_nif.c
parentb4b0029f031818a9dce605b73551bca2ed3a01f4 (diff)
parent0fd671609f7b31a9313d1575434e7273f3f2cd09 (diff)
downloadotp-a30a45e158978a6bc13684505f10d5e3824ee819.tar.gz
otp-a30a45e158978a6bc13684505f10d5e3824ee819.tar.bz2
otp-a30a45e158978a6bc13684505f10d5e3824ee819.zip
Merge branch 'bjorn/asn1/open-type-error/OTP-10805' into maint-r15
* bjorn/asn1/open-type-error/OTP-10805: asn1_erl_nif: Correct broken length encoding asn1_SUITE: Mend broken test_modified_x420/1
Diffstat (limited to 'lib/asn1/c_src/asn1_erl_nif.c')
-rw-r--r--lib/asn1/c_src/asn1_erl_nif.c5
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;