[PATCH] Null Terminated Character Problem
"Mi Reflejo" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
* gw/smsc/smsc_smpp.c -Remove Null Terminated Character from Delivery Reports Some providers like MBLOX send 00 hex character in delivery reports. if handle_dlr does not do any conversion to msgdata when a Delivery Reports comes with 00 hex character the cstr representation of msgdata will put an additional \0 to the end - and when this string is concatenated to another (like when sqlbox does an INSERT statement) the final string has an \0 in the middle. This may affect a lot of operations with the final string.
null_terminated_replace.patch
(application/octet-stream, 1.1 KB)
diff -Nru gw/smsc/smsc_smpp.c.orig gw/smsc/smsc_smpp.c
--- gw/smsc/smsc_smpp.c.orig 2006-05-12 23:43:20.000000000 -0600
+++ gw/smsc/smsc_smpp.c 2006-05-12 23:48:10.000000000 -0600
@@ -1286,6 +1286,8 @@
* The DLR trigger URL is indicated by msg->sms.dlr_url.
*/
dlrmsg->sms.msgdata = octstr_duplicate(respstr);
+ //Remove null terminated characters in the middle of msgdata
+ rm_nullt_from_octstr(dlrmsg->sms.msgdata);
dlrmsg->sms.sms_type = report_mo;
} else {
error(0,"SMPP[%s]: got DLR but could not find message or was not interested "
diff -Nru gwlib/charset.c.orig gwlib/charset.c
--- gwlib/charset.c.orig 2006-05-12 23:36:39.000000000 -0600
+++ gwlib/charset.c 2006-05-12 23:43:15.000000000 -0600
@@ -327,6 +327,17 @@
xmlCleanupEncodingAliases();
}
+void rm_nullt_from_octstr(Octstr *ostr)
+{
+ long pos, len;
+ len = octstr_len(ostr);
+ for (pos = 0; pos < len; pos++) {
+ int c, new, i;
+ c = octstr_get_char(ostr, pos);
+ if (c == 0)
+ octstr_delete(ostr, pos, 1);
+ }
+}
void charset_gsm_to_latin1(Octstr *ostr)
{