[PATCH] Fix bug in at2 7bit encoding with offset

Riku Palomäki <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

There is a bug in function at2_encode7bituncompressed. It doesn't take
the given offset value into consideration when determining the target
octet string length. Therefore it may truncate the target string just
before the last octet.

This leads to corrupted PDU string and sending failure. In practice,
every message fails to deliver if it's splitted to two messages, have
a length of 161 + n*8 characters and is sent with 7 bit GSM charset.

The problem is easily fixed by calculating the destRemain correctly.


Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.50
diff -u -r1.50 smsc_at.c
--- gw/smsc/smsc_at.c	3 Jul 2008 18:24:24 -0000	1.50
+++ gw/smsc/smsc_at.c	10 Jul 2008 13:39:47 -0000
@@ -2426,7 +2426,7 @@
 {
     int LSBmask[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
     int MSBmask[8] = { 0x00, 0x40, 0x60, 0x70, 0x78, 0x7C, 0x7E, 0x7F };
-    int destRemain = (int)ceil ((octstr_len(source) * 7.0) / 8.0);
+    int destRemain = (int)ceil ((octstr_len(source) * 7.0 + offset) / 8.0);
     int i = (offset?8-offset:7), iStore = offset;
     int posT, posS;
     Octstr *target = octstr_create("");



-- 
Riku Palomäki / 4sens Ltd
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.