aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-03-14 14:50:35 +0100
committerBjörn Gustavsson <[email protected]>2013-03-14 14:50:35 +0100
commit5f764a80aab1af1bbae170f8819fe3c3393b0cb6 (patch)
treee747201ce1384c4c917c33077ad04b1eace75ba6 /lib/asn1/src
parent8e44167cb97ccf51a8ee3ca97449613ef3300514 (diff)
parente7f320e1f84da88a96c3bc4a76f43a296a738264 (diff)
downloadotp-5f764a80aab1af1bbae170f8819fe3c3393b0cb6.tar.gz
otp-5f764a80aab1af1bbae170f8819fe3c3393b0cb6.tar.bz2
otp-5f764a80aab1af1bbae170f8819fe3c3393b0cb6.zip
Merge branch 'maint-r16' into maint
* maint-r16: Prepare release PER: Ensure that the complete encoding is at least one byte PER/UPER: Correct decoding of ENUMERATEDs with a single value
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1ct_imm.erl10
-rw-r--r--lib/asn1/src/asn1rtt_per.erl5
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl7
3 files changed, 15 insertions, 7 deletions
diff --git a/lib/asn1/src/asn1ct_imm.erl b/lib/asn1/src/asn1ct_imm.erl
index 869bda5d52..4b2c3b1b65 100644
--- a/lib/asn1/src/asn1ct_imm.erl
+++ b/lib/asn1/src/asn1ct_imm.erl
@@ -61,6 +61,8 @@ optimize_alignment(Imm, Al) ->
per_dec_boolean() ->
{map,{get_bits,1,[1]},[{0,false},{1,true}]}.
+per_dec_enumerated([{V,_}], _Aligned) ->
+ {value,V};
per_dec_enumerated(NamedList0, Aligned) ->
Ub = length(NamedList0) - 1,
Constraint = [{'ValueRange',{0,Ub}}],
@@ -375,6 +377,8 @@ opt_al({call,Fun,E0}, A0) ->
opt_al({convert,Op,E0}, A0) ->
{E,A} = opt_al(E0, A0),
{{convert,Op,E},A};
+opt_al({value,V}=Term, A) when is_integer(V); is_atom(V) ->
+ {Term,A};
opt_al({value,E0}, A0) ->
{E,A} = opt_al(E0, A0),
{{value,E},A};
@@ -391,8 +395,6 @@ opt_al({'case',Cs0}, A0) ->
opt_al({map,E0,Cs}, A0) ->
{E,A} = opt_al(E0, A0),
{{map,E,Cs},A};
-opt_al('NULL'=Null, A) ->
- {Null,A};
opt_al(I, A) when is_integer(I) ->
{I,A}.
@@ -480,8 +482,8 @@ flatten({map,E0,Cs0}, Buf0, St0) ->
{Dst,St2} = new_var("Int", St1),
Cs = flatten_map_cs(Cs0, E),
{{Dst,DstBuf},Pre++[{'map',E,Cs,{Dst,DstBuf}}],St2};
-flatten({value,'NULL'}, Buf0, St0) ->
- {{"'NULL'",Buf0},[],St0};
+flatten({value,V}, Buf0, St0) when is_atom(V) ->
+ {{"'"++atom_to_list(V)++"'",Buf0},[],St0};
flatten({value,V0}, Buf0, St0) when is_integer(V0) ->
{{V0,Buf0},[],St0};
flatten({value,V0}, Buf0, St0) ->
diff --git a/lib/asn1/src/asn1rtt_per.erl b/lib/asn1/src/asn1rtt_per.erl
index 84ff809912..aa6cf4da0a 100644
--- a/lib/asn1/src/asn1rtt_per.erl
+++ b/lib/asn1/src/asn1rtt_per.erl
@@ -963,7 +963,10 @@ encode_relative_oid(Val) when is_list(Val) ->
%%
complete(L) ->
- asn1rt_nif:encode_per_complete(L).
+ case asn1rt_nif:encode_per_complete(L) of
+ <<>> -> <<0>>;
+ Bin -> Bin
+ end.
octets_to_complete(Len,Val) when Len < 256 ->
[20,Len,Val];
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index ad0678f3c3..8efe9a7b0f 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -1016,8 +1016,11 @@ complete(InList) when is_list(InList) ->
Bits -> <<Res/bitstring,0:(8-Bits)>>
end
end;
-complete(InList) when is_binary(InList) ->
- InList;
+complete(Bin) when is_binary(Bin) ->
+ case Bin of
+ <<>> -> <<0>>;
+ _ -> Bin
+ end;
complete(InList) when is_bitstring(InList) ->
PadLen = 8 - (bit_size(InList) band 7),
<<InList/bitstring,0:PadLen>>.