aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-08-10 14:52:31 +0200
committerRaimo Niskanen <[email protected]>2017-08-16 16:28:57 +0200
commit5d33ec9021ff4fa8e3ffac01bdd0228871636edd (patch)
tree5364028375eee410b120d75a3c4c6d36abfd1a31 /lib/asn1/src
parent6ede2da826335960037299d9f3b0e66d072ea5a0 (diff)
downloadotp-5d33ec9021ff4fa8e3ffac01bdd0228871636edd.tar.gz
otp-5d33ec9021ff4fa8e3ffac01bdd0228871636edd.tar.bz2
otp-5d33ec9021ff4fa8e3ffac01bdd0228871636edd.zip
Fix broken handling of default values in extensions for PER
Default values have never worked in extension for PER. Note that for default values in the root part of SEQUENCE, giving a value equal to the DEFAULT value, will result in the same encoding as if asn1_DEFAULT was given. However, that behavior is not promised by the documentation. The documentation says that asn1_DEFAULT should be used for default values. For DEFAULT in extensions, only implement what the documentation promises and nothing more. ERIERL-60
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl6
-rw-r--r--lib/asn1/src/asn1rtt_per_common.erl1
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index 3f1be4febb..aff383479b 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -985,9 +985,11 @@ gen_enc_components_call1(Gen, TopType, [C|Rest], DynamicEnc, Ext) ->
Imm1;
'OPTIONAL' ->
enc_absent(Gen, Element, [asn1_NOVALUE], Imm1);
- {'DEFAULT',Def} ->
+ {'DEFAULT',Def} when Ext =:= noext ->
DefValues = def_values(Type, Def),
- enc_absent(Gen, Element, DefValues, Imm1)
+ enc_absent(Gen, Element, DefValues, Imm1);
+ {'DEFAULT',_} ->
+ enc_absent(Gen, Element, [asn1_DEFAULT], Imm1)
end,
Imm = case Imm2 of
[] -> [];
diff --git a/lib/asn1/src/asn1rtt_per_common.erl b/lib/asn1/src/asn1rtt_per_common.erl
index 2ecc9e4bc7..5b5f47dfee 100644
--- a/lib/asn1/src/asn1rtt_per_common.erl
+++ b/lib/asn1/src/asn1rtt_per_common.erl
@@ -542,6 +542,7 @@ extension_bitmap(_Val, Pos, Limit, Acc) when Pos >= Limit ->
extension_bitmap(Val, Pos, Limit, Acc) ->
Bit = case element(Pos, Val) of
asn1_NOVALUE -> 0;
+ asn1_DEFAULT -> 0;
_ -> 1
end,
extension_bitmap(Val, Pos+1, Limit, (Acc bsl 1) bor Bit).