aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/src/asn1rtt_ber.erl7
-rw-r--r--lib/asn1/src/asn1rtt_per.erl2
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl2
-rw-r--r--lib/asn1/test/asn1_SUITE_data/Constraints.py1
-rw-r--r--lib/asn1/test/testConstraints.erl17
5 files changed, 21 insertions, 8 deletions
diff --git a/lib/asn1/src/asn1rtt_ber.erl b/lib/asn1/src/asn1rtt_ber.erl
index 5fbf116747..34f246fb22 100644
--- a/lib/asn1/src/asn1rtt_ber.erl
+++ b/lib/asn1/src/asn1rtt_ber.erl
@@ -1270,12 +1270,7 @@ check_restricted_string(Val, StrLen, Range) ->
case Range of
{Lb,Ub} when StrLen >= Lb, Ub >= StrLen -> % variable length constraint
Val;
- {{Lb,_Ub},[]} when StrLen >= Lb ->
- Val;
- {{Lb,_Ub},_Ext=[Min|_]} when StrLen >= Lb; StrLen >= Min ->
- Val;
- {{Lb1,Ub1},{Lb2,Ub2}} when StrLen >= Lb1, StrLen =< Ub1;
- StrLen =< Ub2, StrLen >= Lb2 ->
+ {_,Ext} when is_list(Ext) ->
Val;
StrLen -> % fixed length constraint
Val;
diff --git a/lib/asn1/src/asn1rtt_per.erl b/lib/asn1/src/asn1rtt_per.erl
index b8971b7c33..d5952755f8 100644
--- a/lib/asn1/src/asn1rtt_per.erl
+++ b/lib/asn1/src/asn1rtt_per.erl
@@ -356,7 +356,7 @@ encode_length({Lb,Ub}=Vr, Len) when Ub =< 65535 ,Lb >= 0 -> % constrained
encode_length({Lb,_Ub}, Len) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
encode_length(Len);
encode_length({{Lb,Ub}=Vr,Ext}, Len)
- when Ub =< 65535 ,Lb >= 0,Len=<Ub, is_list(Ext) ->
+ when Ub =< 65535, Lb =< Len, Len =< Ub, is_list(Ext) ->
%% constrained extensible
[0|encode_constrained_number(Vr,Len)];
encode_length({{_,_},Ext},Len) when is_list(Ext) ->
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index 3f362d227e..0a543ea6d7 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -355,7 +355,7 @@ encode_length({Lb,Ub}=Vr, Len) when Ub =< 65535, Lb >= 0 -> % constrained
encode_length({Lb,_Ub}, Len) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
encode_length(Len);
encode_length({{Lb,Ub}=Vr,Ext},Len)
- when Ub =< 65535, Lb >= 0, Len =< Ub, is_list(Ext) ->
+ when Ub =< 65535, Lb =< Len, Len =< Ub, is_list(Ext) ->
%% constrained extensible
[<<0:1>>,encode_constrained_number(Vr,Len)];
encode_length({{_Lb,_Ub},Ext}, Len) when is_list(Ext) ->
diff --git a/lib/asn1/test/asn1_SUITE_data/Constraints.py b/lib/asn1/test/asn1_SUITE_data/Constraints.py
index 87243121f7..a069364084 100644
--- a/lib/asn1/test/asn1_SUITE_data/Constraints.py
+++ b/lib/asn1/test/asn1_SUITE_data/Constraints.py
@@ -86,5 +86,6 @@ Document ::= OCTET STRING (ENCODED BY pdf)
pdf OBJECT IDENTIFIER ::= {1,2,3,4,5}
+ShorterExt ::= IA5String (SIZE (5, ...))
END
diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl
index d6db1c2b91..d245f6d1d5 100644
--- a/lib/asn1/test/testConstraints.erl
+++ b/lib/asn1/test/testConstraints.erl
@@ -145,8 +145,16 @@ int_constraints(Rules) ->
[roundtrip('VariableSize', lists:seq($A, $A+L-1)) ||
L <- lists:seq(1, 10)],
+ roundtrip_enc('ShorterExt', "a", shorter_ext(Rules, "a")),
+ roundtrip('ShorterExt', "abcde"),
+ roundtrip('ShorterExt', "abcdef"),
+
ok.
+shorter_ext(per, "a") -> <<16#80,16#01,16#61>>;
+shorter_ext(uper, "a") -> <<16#80,16#E1>>;
+shorter_ext(ber, _) -> none.
+
refed_NNL_name(_Erule) ->
?line {ok,_} = asn1_wrapper:encode('Constraints','AnotherThing',fred),
?line {error,_Reason} =
@@ -160,6 +168,15 @@ roundtrip(Module, Type, Value) ->
{ok,Value} = Module:decode(Type, Encoded),
ok.
+roundtrip_enc(Type, Value, Enc) ->
+ Module = 'Constraints',
+ {ok,Encoded} = Module:encode(Type, Value),
+ {ok,Value} = Module:decode(Type, Encoded),
+ case Enc of
+ none -> ok;
+ Encoded -> ok
+ end.
+
range_error(ber, Type, Value) ->
%% BER: Values outside the effective range should be rejected
%% on decode.