diff options
author | Kenneth Lundin <[email protected]> | 2010-08-23 15:50:13 +0200 |
---|---|---|
committer | Kenneth Lundin <[email protected]> | 2010-08-23 15:50:13 +0200 |
commit | 727ea85b458865daf39fef07a8cd8308420e2a1a (patch) | |
tree | 2c2b8ddaac8c81e4b6bc3e1e2bdfca2b0f4ebc2a /lib/asn1 | |
parent | bdfd2aaa1d402b3dd393a7820432f8f76e248ee1 (diff) | |
download | otp-727ea85b458865daf39fef07a8cd8308420e2a1a.tar.gz otp-727ea85b458865daf39fef07a8cd8308420e2a1a.tar.bz2 otp-727ea85b458865daf39fef07a8cd8308420e2a1a.zip |
Fix bug in UNALIGNED PER regarding encode/decode of constrained number with valuerange > 1024
OTP-8779
Thanks to Vincent de Phily
Diffstat (limited to 'lib/asn1')
-rw-r--r-- | lib/asn1/src/asn1rt_uper_bin.erl | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/lib/asn1/src/asn1rt_uper_bin.erl b/lib/asn1/src/asn1rt_uper_bin.erl index a964b835ae..abe178a69e 100644 --- a/lib/asn1/src/asn1rt_uper_bin.erl +++ b/lib/asn1/src/asn1rt_uper_bin.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -1611,25 +1611,8 @@ complete_NFP(InList) when is_bitstring(InList) -> %% 10.5.6 NOTE: If "range" satisfies the inequality 2^m < "range" =< %% 2^(m+1) then the number of bits = m + 1 -num_bits(1) -> 0; -num_bits(2) -> 1; -num_bits(R) when R =< 4 -> - 2; -num_bits(R) when R =< 8 -> - 3; -num_bits(R) when R =< 16 -> - 4; -num_bits(R) when R =< 32 -> - 5; -num_bits(R) when R =< 64 -> - 6; -num_bits(R) when R =< 128 -> - 7; -num_bits(R) when R =< 256 -> - 8; -num_bits(R) when R =< 512 -> - 9; -num_bits(R) when R =< 1024 -> - 10; -num_bits(R) -> - 1+num_bits(R bsr 1). + +num_bits(N) -> + num_bits(N,1,0). +num_bits(N,T,B) when N=<T->B; +num_bits(N,T,B) ->num_bits(N,T bsl 1, B+1). |