Hi list,

we had a case recently with an SMSC that provided the following SMPP DLR payload:

  id:2516372655 submit date:1604131525 done date:1604131525 stat:DELIVRD

which of course doesn't comply with the official DLR format of SMPP v3.4 spec. Nevertheless, we have a way to scan for needed items of the DLR payload in gw/smsc/smsc_smpp.c, even if the sscanf() way doesn't work out.

But, it was not recognizing the 'stat:DELIVRD' part, due that it assumes there is ALWAYS a ' ' character trailing the item sequence, which is not the case here.

Since we DO only need the msg ID and the stat itself for the DLR lookup, this would result in a false negative state here, since the stat would not be recognized and defaults to DLR FAIL.

The following patch simply takes into account that the "fallback mode" scan does obey that an item MAY end in the end-of-line, without a space. It does not impact any current pattern matching.

If qualified objections arise, I will be committing the patch these days.

--
Best Regards,
Stipe Tolj

-------------------------------------------------------------------
Düsseldorf, NRW, Germany

Kannel Foundation                 tolj.org system architecture
http://www.kannel.org/            http://www.tolj.org/

stolj at kannel.org               st at tolj.org
-------------------------------------------------------------------
Index: gw/smsc/smsc_smpp.c
===================================================================
--- gw/smsc/smsc_smpp.c (revision 5150)
+++ gw/smsc/smsc_smpp.c (working copy)
@@ -1539,31 +1539,32 @@
                 dlr_err = octstr_create(err_cstr);
                 octstr_strip_blanks(dlr_err);
             } else {
-                debug("bb.sms.smpp", 0, "SMPP[%s]: Couldnot parse DLR string 
sscanf way,"
+                debug("bb.sms.smpp", 0, "SMPP[%s]: Could not parse DLR string 
sscanf way, "
                       "fallback to old way. Please report!", 
octstr_get_cstr(smpp->conn->id));
 
                 /* only if not already here */
                 if (msgid == NULL) {
                     if ((curr = octstr_search(respstr, octstr_imm("id:"), 0)) 
!= -1) {
-                        vpos = octstr_search_char(respstr, ' ', curr);
-                        if ((vpos-curr >0) && (vpos != -1))
+                        if ((vpos = octstr_search_char(respstr, ' ', curr)) == 
-1)
+                            vpos = octstr_len(respstr);
+                        if (vpos-curr > 0)
                             msgid = octstr_copy(respstr, curr+3, vpos-curr-3);
-                    } else {
-                        msgid = NULL;
-                    }
+                    } 
                 }
 
                 /* get err & status code */
                 if ((curr = octstr_search(respstr, octstr_imm("stat:"), 0)) != 
-1) {
-                    vpos = octstr_search_char(respstr, ' ', curr);
-                    if ((vpos-curr >0) && (vpos != -1))
+                    if ((vpos = octstr_search_char(respstr, ' ', curr)) == -1)
+                        vpos = octstr_len(respstr);
+                    if (vpos-curr > 0)
                         stat = octstr_copy(respstr, curr+5, vpos-curr-5);
                 } else {
                     stat = NULL;
                 }
                 if ((curr = octstr_search(respstr, octstr_imm("err:"), 0)) != 
-1) {
-                    vpos = octstr_search_char(respstr, ' ', curr);
-                    if ((vpos-curr >0) && (vpos != -1))
+                    if ((vpos = octstr_search_char(respstr, ' ', curr)) == -1)
+                        vpos = octstr_len(respstr);
+                    if (vpos-curr > 0)
                         dlr_err = octstr_copy(respstr, curr+4, vpos-curr-4);
                 } else {
                     dlr_err = NULL;

Reply via email to