[PATCH] utils/mtabatch.c
"Nikos Balkanas" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <008601c9e92d$36b68060$02b2a8c0@tardis> |
Hi, This is a simple patch to mtbatch, that if left as is should core dump. BR, Nikos
mtbatch.diff
(application/octet-stream, 1.9 KB)
Index: utils/mtbatch.c
===================================================================
RCS file: /home/cvs/gateway/utils/mtbatch.c,v
retrieving revision 1.16
diff -a -u -r1.16 mtbatch.c
--- utils/mtbatch.c 30 Apr 2009 12:12:30 -0000 1.16
+++ utils/mtbatch.c 9 Jun 2009 18:03:01 -0000
@@ -200,41 +200,47 @@
* Return >= 0 for success & count of splitted sms messages,
* -1 for failure. Does not destroy the msg.
*/
+
static int send_message(Msg *msg)
{
unsigned long msg_count;
List *list;
-
+ Msg *part;
+ int i;
+
gw_assert(msg != NULL);
gw_assert(msg_type(msg) == sms);
-
- /*
- * Encode our smsbox-id to the msg structure.
+
+ /*
+ * Encode our sm-id to the msg structure.
* This will allow bearerbox to return specific answers to the
* same smsbox, mainly for DLRs and SMS proxy modes.
*/
if (smsbox_id != NULL) {
msg->sms.boxc_id = octstr_duplicate(smsbox_id);
}
-
+
list = sms_split(msg, NULL, NULL, NULL, NULL, 1, 0, 100, MAX_SMS_OCTETS);
msg_count = gwlist_len(list);
- gwlist_destroy(list, msg_destroy_item);
-
debug("sms", 0, "message length %ld, sending %ld messages",
octstr_len(msg->sms.msgdata), msg_count);
- if (delay > 0)
- gwthread_sleep(delay);
+ for (i = 0; i < msg_count; i++)
+ {
+ part = gwlist_get(list, i);
+ /* pass message to bearerbox */
+ if (deliver_to_bearerbox(part) != 0)
+ {
+ gwlist_destroy(list, msg_destroy_item);
+ return -1;
+ }
+ if (delay > 0) gwthread_sleep(delay);
+ }
- /* pass message to bearerbox */
- if (deliver_to_bearerbox(msg) != 0)
- return -1;
-
+ gwlist_destroy(list, msg_destroy_item);
return msg_count;
}
-
static void help(void)
{
info(0, "Usage: mtbatch [options] content-file receivers-file ...");