K2InformaticsGmbH / smpp_parser

A parser for SMPP protocol PDUs
Apache License 2.0
3 stars 1 forks source link

decode ->encode->decode corrupting delivery_failure_reason #43

Closed c-bik closed 6 years ago

c-bik commented 6 years ago

delivery_failure_reason (4.8.4.19) TLV

S = <<"00 00 00 3B 80 00 00 21 00 00 00 00 89 CB F7 51 74 68 69 73 5F 63 6F 75 6C "
      "64 5F 62 65 5F 61 5F 6D 65 73 73 61 67 65 5F 69 64 00 00 04 25 00 01 03 04 "
      "25 00 01 02 04 20 00 01 01">>.
> {ok, S1} = smpp:decode(S).
{ok,#{command_id => <<"submit_multi_resp">>,command_length => 59,
      command_status => <<"ESME_ROK">>,
      delivery_failure_reason => 3,dpf_result => 1,
      message_id => <<"this_could_be_a_message_id">>,
      sequence_number => 2311845713,
      tlvs => [#{len => 1,tag => 1061,val => <<2>>}],
      unsuccess_sme => <<>>}}
{ok, S2} = smpp:encode(S1).
> smpp:decode(S2).           
{ok,#{command_id => <<"submit_multi_resp">>,command_length => 59,
      command_status => <<"ESME_ROK">>,
      delivery_failure_reason => 2,dpf_result => 1,
      message_id => <<"this_could_be_a_message_id">>,
      sequence_number => 2311845713,
      tlvs => [#{len => 1,tag => 1061,val => <<3>>}],
      unsuccess_sme => <<>>}}

delivery_failure_reason is changed from 3 to 2 after one decode ->encode->decode cycle

c-bik commented 6 years ago

PDU malformed, known TLV used twice!

00 00 00 3B
80 00 00 21
00 00 00 00
89 CB F7 51 74 68 69 73 5F 63 6F 75 6C 64 5F 62 65 5F 61 5F 6D 65 73 73 61 67 65 5F 69 64 00 00
04 25 00 01 03 - delivery_failure_reason
04 25 00 01 02 - delivery_failure_reason
04 20 00 01 01 - dpf_result