diff options
author | Björn Gustavsson <[email protected]> | 2012-12-12 15:12:25 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-12-19 11:52:12 +0100 |
commit | 1749a097ef9871124e6d2eecf2c6644f0c133fcc (patch) | |
tree | ab91b262c0f62bcdc9490e6ca6c570acdcb94774 | |
parent | 3d1279f3cebfdd2483c3afea9f225613fe45cd00 (diff) | |
download | otp-1749a097ef9871124e6d2eecf2c6644f0c133fcc.tar.gz otp-1749a097ef9871124e6d2eecf2c6644f0c133fcc.tar.bz2 otp-1749a097ef9871124e6d2eecf2c6644f0c133fcc.zip |
per: Fix encoding of OCTET STRINGs with fixed length of 256 or more
-rw-r--r-- | lib/asn1/src/asn1ct_gen_per_rt2ct.erl | 4 | ||||
-rw-r--r-- | lib/asn1/test/asn1_SUITE_data/PrimStrings.asn1 | 13 | ||||
-rw-r--r-- | lib/asn1/test/testPrimStrings.erl | 5 |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl index 2f47f6efb8..fa9c3645b3 100644 --- a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl +++ b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl @@ -416,7 +416,7 @@ emit_enc_octet_string(_Erules,Constraint,Value) -> {next,tmpval},"]]",nl}), emit(" end"), asn1ct_name:new(tmpval); - Sv when is_integer(Sv),Sv =< 256 -> + Sv when is_integer(Sv),Sv < 256 -> asn1ct_name:new(tmpval), emit({" begin",nl}), emit({" case length(",Value,") of",nl}), @@ -430,7 +430,7 @@ emit_enc_octet_string(_Erules,Constraint,Value) -> emit({" begin",nl}), emit({" case length(",Value,") of",nl}), emit([" ",{curr,tmpval}," when ",{curr,tmpval}," == ",Sv," ->"]), - emit([" [2,21,",{curr,tmpval},",",Value,"];",nl]), + emit([" [<<21,",{curr,tmpval},":16>>|",Value,"];",nl]), emit({" _ -> exit({error,{value_out_of_bounds,", Value,"}})",nl," end",nl}), emit(" end"); diff --git a/lib/asn1/test/asn1_SUITE_data/PrimStrings.asn1 b/lib/asn1/test/asn1_SUITE_data/PrimStrings.asn1 index 7cb47e9792..9b6b34a776 100644 --- a/lib/asn1/test/asn1_SUITE_data/PrimStrings.asn1 +++ b/lib/asn1/test/asn1_SUITE_data/PrimStrings.asn1 @@ -59,6 +59,19 @@ BS1024 ::= BIT STRING (SIZE (1024)) FixedOs65536 ::= OCTET STRING (SIZE (65536)) FixedOs65537 ::= OCTET STRING (SIZE (65537)) + OsFixedStrings ::= SEQUENCE { + b1 BOOLEAN, -- Unalign + s0 OCTET STRING (SIZE (0)), + s1 OCTET STRING (SIZE (1)), + s2 OCTET STRING (SIZE (2)), + s3 OCTET STRING (SIZE (3)), + b2 BOOLEAN, -- Unalign + s255 OCTET STRING (SIZE (255)), + s256 OCTET STRING (SIZE (256)), + s257 OCTET STRING (SIZE (257)), + i INTEGER (0..1024) + } + OsAlignment ::= SEQUENCE { b1 BOOLEAN, s1 Os, diff --git a/lib/asn1/test/testPrimStrings.erl b/lib/asn1/test/testPrimStrings.erl index 9a640a2cb1..263d9e5ed2 100644 --- a/lib/asn1/test/testPrimStrings.erl +++ b/lib/asn1/test/testPrimStrings.erl @@ -372,6 +372,11 @@ octet_string(Rules) -> end, fragmented_octet_string(Rules), + + S255 = lists:seq(1, 255), + FixedStrings = {'OsFixedStrings',true,"","1","12","345",true, + S255,[$a|S255],[$a,$b|S255],397}, + roundtrip('OsFixedStrings', FixedStrings), ok. fragmented_octet_string(Erules) -> |