[PATCH] Better nosmsc handling
"Stanisław Pitucha" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello This patch allows to receive message with no smsc number included (len=0) - it will not crash, even if no-smsc is not set. Fixes http://bugs.kannel.org/view.php?id=385 Second part checks for 0-length pdu part in gsm2number(). Otherwise it will get stuck resizing string in while(--len). Or maybe it should be assert?
smsc_at.c.diff
(application/unknown, 1.1 KB)
Index: smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.33
diff -u -r1.33 smsc_at.c
--- smsc_at.c 7 Jan 2007 23:52:53 -0000 1.33
+++ smsc_at.c 22 Feb 2007 12:03:51 -0000
@@ -1487,6 +1487,10 @@
+ at2_hexchar(octstr_get_char(buffer, pos + 1));
if (tmp < 0)
goto nomsg;
+ if (tmp == 0) {
+ info(0, "AT2[%s]: received message without smsc number - consider setting no-smsc", octstr_get_cstr(privdata->name));
+ goto nosmsc;
+ }
numtmp = octstr_create_from_data(octstr_get_cstr(buffer)+pos+2,tmp * 2); /* we now have the hexchars of the SMSC in GSM encoding */
octstr_hex_to_binary(numtmp);
@@ -1498,6 +1502,7 @@
pos += 2 + tmp * 2;
}
+nosmsc:
/* check if the buffer is long enough to contain the full message */
if (!privdata->modem->broken && octstr_len(buffer) < len * 2 + pos)
goto nomsg;
@@ -1537,6 +1542,8 @@
pos=0;
len = octstr_len(pdu);
+ if(len==0)
+ return octstr_create("");
ton = octstr_get_char(pdu,pos++);
npi = ton & 0x0F;