aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-03-12 08:35:48 +0100
committerBjörn Gustavsson <[email protected]>2013-03-12 08:49:12 +0100
commit5588449531f1a41d05e5d2d4fe5976db643a18e3 (patch)
tree8cbbc7f41ff0aac9fd0096af4e63de18d44aee91 /lib/asn1/src
parent7c1786ef06498a80f982aa08da30e3775184c5d3 (diff)
downloadotp-5588449531f1a41d05e5d2d4fe5976db643a18e3.tar.gz
otp-5588449531f1a41d05e5d2d4fe5976db643a18e3.tar.bz2
otp-5588449531f1a41d05e5d2d4fe5976db643a18e3.zip
PER: Ensure that the complete encoding is at least one byte
If the encoding is empty (i.e. if a top-level type is single-valued and therefore not encoding), the result should be a single zero byte.
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1rtt_per.erl5
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl7
2 files changed, 9 insertions, 3 deletions
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>>.