aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-09-27 14:11:54 +0200
committerBjörn Gustavsson <[email protected]>2013-10-01 14:54:54 +0200
commit6baa1883a9c7f4d9b4be76d1375cf8b2cc614797 (patch)
tree1d1fd32191b4c85dfb3a7479529fe8c33489afed /lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
parent0f430abcb189988a7faf55386557b2b74afa6f56 (diff)
downloadotp-6baa1883a9c7f4d9b4be76d1375cf8b2cc614797.tar.gz
otp-6baa1883a9c7f4d9b4be76d1375cf8b2cc614797.tar.bz2
otp-6baa1883a9c7f4d9b4be76d1375cf8b2cc614797.zip
Fix broken handling of default values for BIT STRINGs
For DER/PER/UPER, a value equal to the DEFAULT is not supposed to be encoded. BIT STRINGs values can be represented as Erlang terms in four different ways: as an integer, as a list of zeroes and ones, as a {Unused,Binary} tuple, or as an Erlang bitstring. When encoding a BIT STRING, only certain representations of BIT STRINGs values were recognized. All representations must be recognized. When decoding a DEFAULT value for a BIT STRING, the actual value given in the decoding would be either an integer or a list of zeroes and one (depending on how the literal was written in the specification). We expect that the default value should be in the same representation as any other BIT STRING value (i.e. by default an Erlang bitstring, or a list if the 'legacy_bitstring' option has been given, or as compact bitstring if 'compact_bitstring' has been given).
Diffstat (limited to 'lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl')
-rw-r--r--lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
index 8359b81b33..a38da8bcc2 100644
--- a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
@@ -1155,7 +1155,8 @@ gen_dec_line(Erules,TopType,Cname,CTags,Type,OptOrMand,DecObjInf) ->
emit([indent(4),"_ ->",nl]),
case OptOrMand of
- {'DEFAULT', Def} ->
+ {'DEFAULT', Def0} ->
+ Def = asn1ct_gen:conform_value(Type, Def0),
emit([indent(8),"{",{asis,Def},",",{prev,tlv},"}",nl]);
'OPTIONAL' ->
emit([indent(8),"{ asn1_NOVALUE, ",{prev,tlv},"}",nl])