From ee622028a78986a28088959318df02caa762d1da Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 6 Aug 2015 14:44:41 +0200 Subject: [PATCH 1/2] Can now handle 0-length messages. --- smppclient.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/smppclient.class.php b/smppclient.class.php index 7732471..5fae17a 100644 --- a/smppclient.class.php +++ b/smppclient.class.php @@ -518,7 +518,11 @@ protected function parseSMS(SmppPdu $pdu) $dataCoding = next($ar); next($ar); // sm_default_msg_id $sm_length = next($ar); - $message = $this->getString($ar,$sm_length); + if ($sm_length > 0) { // Most var-length values in smpp are null-terminated. + $message = $this->getString($ar, $sm_length); // for some reason, message is not, so it needs an if here. + } else { // probably $this->getString() doesnt work fully as expected + $message = null; // but this is a quick walkaround + } // Check for optional params, and parse them if (current($ar) !== false) { From b2398526994697bcd7ae6092fae31053af4fded8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 6 Aug 2015 14:47:20 +0200 Subject: [PATCH 2/2] Better problem description --- smppclient.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smppclient.class.php b/smppclient.class.php index 5fae17a..428684f 100644 --- a/smppclient.class.php +++ b/smppclient.class.php @@ -518,10 +518,10 @@ protected function parseSMS(SmppPdu $pdu) $dataCoding = next($ar); next($ar); // sm_default_msg_id $sm_length = next($ar); - if ($sm_length > 0) { // Most var-length values in smpp are null-terminated. - $message = $this->getString($ar, $sm_length); // for some reason, message is not, so it needs an if here. - } else { // probably $this->getString() doesnt work fully as expected - $message = null; // but this is a quick walkaround + if ($sm_length > 0) { // getString is doing "next()" on $ar + $message = $this->getString($ar, $sm_length); // but it shouldn't for 0-length,not-null-terminated value + } else { + $message = null; } // Check for optional params, and parse them