K2InformaticsGmbH / smpp_parser

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

possible malformed TLV or bad parsing #104

Closed c-bik closed 6 years ago

c-bik commented 6 years ago
> PDU = "00 00 00 82 00 00 00 04 00 00 00 00 00 00 00 01 47 55 54 53 00 03 01 31 36 38 2E 30 2E 30 2E 31 00 01 08 31 39 32 2E 31 2E 31 2E 31 30 00 01 00 02 39 39 30 39 32 32 31 35 35 32 34 32 33 34 36 2D 00 39 39 30 34 32 37 32 30 30 30 30 30 30 30 30 2B 00 01 00 01 7F 17 54 68 69 73 20 69 73 20 61 20 73 68 6F 72 74 20 6D 65 73 73 61 67 65 06 0D 00 1E 33 31 31 30 39 31 32 38 31 37 33 30 36 35 00".
> Bin = list_to_binary([binary_to_integer(B, 16) || B <- re:split(PDU, " ")]).
> SMPP1 = lists:foldl(fun smpp:list_to_map/2, #{}, smpp:unpack(Bin)).
Unpack error {'ESME_RINVTLVSTREAM',"ESME_RINVTLVSTREAM",
                                   "Error in the optional part of the PDU Body"}
** exception error: no function clause matching lists:foldl(#Fun<smpp.list_to_map.2>,#{},{error,4,192,1}) (lists.erl, line 1262)
shamis commented 6 years ago

the length of the source_network_id TLV is set as 1E where the TLV length is only 0F.


> PDU = "00 00 00 82 00 00 00 04 00 00 00 00 00 00 00 01 47 55 54 53 00 03 01 31 36 38 2E 30 2E 30 2E 31 00 01 08 31 39 32 2E 31 2E 31 2E 31 30 00 01 00 02 39 39 30 39 32 32 31 35 35 32 34 32 33 34 36 2D 00 39 39 30 34 32 37 32 30 30 30 30 30 30 30 30 2B 00 01 00 01 7F 17 54 68 69 73 20 69 73 20 61 20 73 68 6F 72 74 20 6D 65 73 73 61 67 65 06 0D 00 0F 33 31 31 30 39 31 32 38 31 37 33 30 36 35 00".
> smpp:decode(PDU).
{ok,#{command_id => <<"submit_sm">>,command_length => 130,
      command_status => <<"ESME_ROK">>,
      data_coding => <<"IA5 (CCITT T.50)/ASCII (ANSI X3.4)">>,
      dest_addr_npi => <<"National">>,
      dest_addr_ton => <<"International">>,
      destination_addr => <<"192.1.1.10">>,esm_class => 1,
      priority_flag => 2,protocol_id => 0,
      registered_delivery => 1,replace_if_present_flag => 0,
      schedule_delivery_time => <<"990922155242346-">>,
      sequence_number => 1,service_type => <<"GUTS">>,
      short_message => <<"This is a short message">>,
      sm_default_msg_id => 127,source_addr => <<"168.0.0.1">>,
      source_addr_npi => <<"ISDN (E163/E164)">>,
      source_addr_ton => <<"Network Specific">>,
      source_network_id => <<"31109128173065">>,
      validity_period => <<"990427200000000+">>}}