diff options
author | Anders Svensson <[email protected]> | 2013-10-11 13:12:32 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-11-03 11:32:45 +0100 |
commit | 838856bde63c0c1089d0a4dab42a532e1420444f (patch) | |
tree | 3367c6e381d46371be18d149beb9be9dd2ed0ff0 /lib/diameter/src/base/diameter_types.erl | |
parent | 20641fe0f2ea745873fc7557448d3a7deb1bd639 (diff) | |
download | otp-838856bde63c0c1089d0a4dab42a532e1420444f.tar.gz otp-838856bde63c0c1089d0a4dab42a532e1420444f.tar.bz2 otp-838856bde63c0c1089d0a4dab42a532e1420444f.zip |
Fix handling of 5014, DIAMETER_INVALID_AVP_LENGTH
The error was detected as 5004 (DIAMETER_INVALID_AVP_VALUE) for
stringish Diameter types, in which case an AVP length that pointed past
the end of a message resulted in encode failure of the suggested
Failed-AVP.
Should have been fixed in commit 4ce2d3a6.
Diffstat (limited to 'lib/diameter/src/base/diameter_types.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_types.erl | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/diameter/src/base/diameter_types.erl b/lib/diameter/src/base/diameter_types.erl index 8c07e84777..ca3338be5f 100644 --- a/lib/diameter/src/base/diameter_types.erl +++ b/lib/diameter/src/base/diameter_types.erl @@ -92,6 +92,9 @@ when is_binary(Bin) -> binary_to_list(Bin); +'OctetString'(decode, B) -> + ?INVALID_LENGTH(B); + 'OctetString'(encode = M, zero) -> 'OctetString'(M, []); @@ -255,9 +258,7 @@ 2 == A, 16 == size(B) -> list_to_tuple([N || <<N:A/unit:8>> <= B]); -'Address'(decode, <<A:16, _/binary>> = B) - when 1 == A; - 2 == A -> +'Address'(decode, B) -> ?INVALID_LENGTH(B); 'Address'(encode, T) -> @@ -278,7 +279,10 @@ <<_,_/binary>> = 'OctetString'(M, X); 'DiameterIdentity'(decode = M, <<_,_/binary>> = X) -> - 'OctetString'(M, X). + 'OctetString'(M, X); + +'DiameterIdentity'(decode, X) -> + ?INVALID_LENGTH(X). %% -------------------- @@ -286,6 +290,9 @@ when is_binary(Bin) -> scan_uri(Bin); +'DiameterURI'(decode, B) -> + ?INVALID_LENGTH(B); + %% The minimal DiameterURI is "aaa://x", 7 characters. 'DiameterURI'(encode = M, zero) -> 'OctetString'(M, lists:duplicate(0,7)); @@ -330,9 +337,13 @@ %% -------------------- -'UTF8String'(decode, Bin) -> +'UTF8String'(decode, Bin) + when is_binary(Bin) -> tl([0|_] = unicode:characters_to_list([0, Bin])); %% assert list return +'UTF8String'(decode, B) -> + ?INVALID_LENGTH(B); + 'UTF8String'(encode = M, zero) -> 'UTF8String'(M, []); |