Skip Menu |

This queue is for tickets about the Net-SMPP CPAN distribution.

Report information
The Basics
Id: 55194
Status: open
Priority: 0/
Queue: Net-SMPP

People
Owner: Nobody in particular
Requestors: dave.cabot [...] ossengineering.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in encode_optional_params
Date: Wed, 3 Mar 2010 14:41:08 -0500
To: bug-Net-SMPP [...] rt.cpan.org
From: David Cabot <dave.cabot [...] ossengineering.com>
SMPP.pm, starting at line 547: if ($param_by_name{$opt_param}) { $data .= pack 'nna*', $param_by_name{$opt_param}, length($val), $val; } elsif ($opt_param =~ /^\d+$/) { # specification by numeric tag * $data .= pack 'nna*', $opt_param, , length($val), $val;* } else { warn "Unknown optional parameter `$opt_param', skipping"; } Two bugs actually. Note the double commas on line 550. Secondly, if we're trying to encode an integer larger than 99, say 12345, then length is going to return 5 while pack is going to encode just 2 bytes. This mangles the ASN.1 and the packet. Problem is, I don't have an easy solution as to how to resolve it. How would you know if a specific optional is supposed to be text, BCD, or integer?
CC: sampo [...] symlabs.com, dave.cabot [...] ossengineering.com
Subject: Re: [rt.cpan.org #55194] Bug in encode_optional_params
Date: Wed, 3 Mar 2010 23:29:01 +0100 (CET)
To: bug-Net-SMPP [...] rt.cpan.org
From: sampo [...] symlabs.com
David Cabot via RT wrote: Show quoted text
> Wed Mar 03 14:42:53 2010: Request 55194 was acted upon. > Transaction: Ticket created by dave.cabot@ossengineering.com > Queue: Net-SMPP > Subject: Bug in encode_optional_params > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: dave.cabot@ossengineering.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=55194 > > > > SMPP.pm, starting at line 547: > > if ($param_by_name{$opt_param}) { > $data .= pack 'nna*', $param_by_name{$opt_param}, > length($val), > $val; > } elsif ($opt_param =~ /^\d+$/) { # specification by numeric tag > * $data .= pack 'nna*', $opt_param, , length($val), $val;*
--^ This star is wrong. ------------------------------------------------^ This comma seems wrong. Show quoted text
> } else { > warn "Unknown optional parameter `$opt_param', skipping"; > } > > Two bugs actually. Note the double commas on line 550. > > Secondly, if we're trying to encode an integer larger than 99, say 12345, > then length is going to return 5 while pack is going to encode just 2 > bytes. This mangles the ASN.1 and the packet.
Oops. Try this --- SMPP.pm.orig 2010-03-03 21:16:36.000000000 +0000 +++ SMPP.pm 2010-03-03 21:30:36.000000000 +0000 @@ -547,7 +547,13 @@ if ($param_by_name{$opt_param}) { $data .= pack 'nna*', $param_by_name{$opt_param}, length($val), $val; } elsif ($opt_param =~ /^\d+$/) { # specification by numeric tag - $data .= pack 'nna*', $opt_param, , length($val), $val; + if ($val > -128 && $val < 127) { + $data .= pack 'nnc', $opt_param, 1, $val; + } elsif ($val > -32768 && $val < 32767) { + $data .= pack 'nnn!', $opt_param, 2, $val; + } else { + $data .= pack 'nnN!', $opt_param, 4, $val; + } } else { warn "Unknown optional parameter `$opt_param', skipping"; } Show quoted text
> Problem is, I don't have an easy solution as to how to resolve it. How > would you know if a specific optional is supposed to be text, BCD, or > integer?
No easy way to know. Hopefully most optional parameters are just small integers. Worst case might be something like a telephone number which should absolutely stay string. Cheers, --Sampo