diff options
author | Anders Svensson <[email protected]> | 2015-04-03 11:17:58 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2015-04-03 11:55:04 +0200 |
commit | 1732c9c9bd6b261cb18f2ff174a8c4d1b9488f3e (patch) | |
tree | 79e9b814450318ef5dcc0534b60be6a174e4e33d /lib/diameter/src | |
parent | 545890576542e4be630df8772654b99bd0306f62 (diff) | |
download | otp-1732c9c9bd6b261cb18f2ff174a8c4d1b9488f3e.tar.gz otp-1732c9c9bd6b261cb18f2ff174a8c4d1b9488f3e.tar.bz2 otp-1732c9c9bd6b261cb18f2ff174a8c4d1b9488f3e.zip |
Remove extra avp bit from diameter_avp decode
In the case of a faulty AVP Length (pointing past the end of a message
or not spanning the header), an extra bit is prepended to data bytes in
diameter_avp:collect_avps/1 in order to force a 5014 decode error. The
bit is supposed to be removed as part of the decode in diameter_gen.hrl
but this didn't happen in case of an AVP that unknown to the dictionary
in question.
Diffstat (limited to 'lib/diameter/src')
-rw-r--r-- | lib/diameter/src/base/diameter_codec.erl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/diameter/src/base/diameter_codec.erl b/lib/diameter/src/base/diameter_codec.erl index 15a4c5e86f..bf2fe8e7ca 100644 --- a/lib/diameter/src/base/diameter_codec.erl +++ b/lib/diameter/src/base/diameter_codec.erl @@ -640,8 +640,12 @@ split_data(Bin, Len) -> %% payload if this is a request. Do this (in cases that we %% know the type) by inducing a decode failure and letting %% the dictionary's decode (in diameter_gen) deal with it. - %% Here we don't know type. If the type isn't known, then - %% the decode just strips the extra bit. + %% + %% Note that the extra bit can only occur in the trailing + %% AVP of a message or Grouped AVP, since a faulty AVP + %% Length is otherwise indistinguishable from a correct + %% one here, since we don't know the types of the AVPs + %% being extracted. {<<0:1, Bin/binary>>, <<>>} end. @@ -690,8 +694,8 @@ pack_avp(#diameter_avp{code = undefined, data = B}) Len = size(<<H:5/binary, _:24, T/binary>> = <<B/binary, 0:Pad>>), <<H/binary, Len:24, T/binary>>; -%% ... from a dictionary compiled against old code in diameter_gen ... %% ... when ignoring errors in Failed-AVP ... +%% ... during a relay encode ... pack_avp(#diameter_avp{data = <<0:1, B/binary>>} = A) -> pack_avp(A#diameter_avp{data = B}); |