Hi,

On Sunday 07 March 2004 18:41, Nisan Bloch wrote:
> Hi
>
> but the way it is at the moment it causes bearerbox to crash while trying
> to access the NULL conn pointer

then me must check for NULL pointer but not just silently drop message because 
"we were too lazy" to check this...

Please test/comment attached patch.

>
> nisan
>
> At 03:21 PM 2004/03/06, Alexander Malysh wrote:
> >Hi,
> >
> >-1 from me for this patch.
> >we want log failed messages into access log instead of just silently drop
> >those.
> >
> >On Thursday 04 March 2004 23:09, Nisan Bloch wrote:
> > > Hi
> > >
> > > A patch for bb_smscconn.c
> > >
> > > bb_smscconn.c:sms_router calls bb_smscconn_send_failed with a NULL
> > > value for conn
> > >        bb_smscconn_send_failed(NULL, msg, ................
> > >
> > > bb_smscconn_send_failed does not check for this and tries to use conn.
> > >
> > > Nisan
> >
> >--
> >Best regards / Mit besten Gr��en aus D�sseldorf
> >
> >Dipl.-Ing.
> >Alexander Malysh
> >___________________________________________
> >
> >Centrium GmbH
> >Vogelsanger Weg 80
> >40470 D�sseldorf
> >
> >Fon: +49 (0211) 74 84 51 80
> >Fax: +49 (0211) 277 49 109
> >
> >email: a.malysh at centrium.de
> >web: www.centrium.de
> >msn: olek2002 at hotmail.com
> >icq: 98063111
> >___________________________________________
> >
> >Please avoid sending me Word, Excel or PowerPoint attachments.
> >See http://www.fsf.org/philosophy/no-word-attachments.html

-- 
Best regards / Mit besten Gr��en aus D�sseldorf

Dipl.-Ing.
Alexander Malysh
___________________________________________

Centrium GmbH
Vogelsanger Weg 80
40470 D�sseldorf

Fon: +49 (0211) 74 84 51 80
Fax: +49 (0211) 277 49 109

email: a.malysh at centrium.de
web: www.centrium.de
msn: olek2002 at hotmail.com
icq: 98063111
___________________________________________

Please avoid sending me Word, Excel or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
Index: gw/bb_alog.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_alog.c,v
retrieving revision 1.3
diff -a -u -r1.3 bb_alog.c
--- gw/bb_alog.c	22 Jan 2004 14:08:24 -0000	1.3
+++ gw/bb_alog.c	7 Mar 2004 18:25:10 -0000
@@ -235,9 +235,12 @@
 	    break;
 
 	case 'i':
-	    if (msg->sms.smsc_id == NULL)
-            break;
-	    octstr_append(result, msg->sms.smsc_id);
+	    if (conn && smscconn_id(conn))
+	        octstr_append(result, smscconn_id(conn));
+	    else if (conn && smscconn_name(conn))
+	        octstr_append(result, smscconn_name(conn));
+	    else if (msg->sms.smsc_id)
+	        octstr_append(result, msg->sms.smsc_id);
 	    break;
 
 	case 'I':
@@ -331,15 +334,22 @@
 
 void bb_alog_sms(SMSCConn *conn, Msg *sms, char *message)
 {
-    Octstr *text, *udh;
-
-    text = udh = NULL;
-
     /* if we don't have any custom log, then use our "default" one */
     
     if (custom_log_format == NULL) {
-        text = sms->sms.msgdata ? octstr_duplicate(sms->sms.msgdata) : octstr_create("");
-        udh = sms->sms.udhdata ? octstr_duplicate(sms->sms.udhdata) : octstr_create("");
+        Octstr *text = sms->sms.msgdata ? octstr_duplicate(sms->sms.msgdata) : octstr_create("");
+        Octstr *udh = sms->sms.udhdata ? octstr_duplicate(sms->sms.udhdata) : octstr_create("");
+        Octstr *cid = NULL;
+
+        if (conn && smscconn_id(conn))
+            cid = smscconn_id(conn);
+        else if (conn && smscconn_name(conn))
+            cid = smscconn_name(conn);
+        else if (sms->sms.smsc_id)
+            cid = sms->sms.smsc_id;
+        else
+            cid = octstr_imm("");
+
         if ((sms->sms.coding == DC_8BIT || sms->sms.coding == DC_UCS2))
             octstr_binary_to_hex(text, 1);
         octstr_binary_to_hex(udh, 1);
@@ -347,7 +357,7 @@
         alog("%s [SMSC:%s] [SVC:%s] [ACT:%s] [BINF:%s] [from:%s] [to:%s] [flags:%d:%d:%d:%d:%d] "
              "[msg:%d:%s] [udh:%d:%s]",
              message,
-             conn ? (smscconn_id(conn) ? octstr_get_cstr(smscconn_id(conn)) : "") : "",
+             octstr_get_cstr(cid),
              sms->sms.service ? octstr_get_cstr(sms->sms.service) : "",
              sms->sms.account ? octstr_get_cstr(sms->sms.account) : "",
              sms->sms.binfo ? octstr_get_cstr(sms->sms.binfo) : "",
@@ -359,13 +369,13 @@
              octstr_len(sms->sms.udhdata), octstr_get_cstr(udh)
         );
 
+        octstr_destroy(udh);
+        octstr_destroy(text);
     } else {
-        text = get_pattern(conn, sms, message);
-        alog("%s", octstr_get_cstr(text));
+        Octstr *text = get_pattern(conn, sms, message);
+        alog(octstr_get_cstr(text));
     }
 
-    octstr_destroy(udh);
-    octstr_destroy(text);
 }
 
 
Index: gw/bb_smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_smscconn.c,v
retrieving revision 1.73
diff -a -u -r1.73 bb_smscconn.c
--- gw/bb_smscconn.c	10 Feb 2004 22:38:57 -0000	1.73
+++ gw/bb_smscconn.c	7 Mar 2004 18:25:10 -0000
@@ -227,7 +227,7 @@
 	        reply = octstr_create("");
 
 	    octstr_insert_data(reply, 0, "NACK/", 5);
-            dlrmsg = create_dlr_from_msg((conn->id?conn->id:conn->name), sms,
+            dlrmsg = create_dlr_from_msg((conn ? (conn->id?conn->id:conn->name) : NULL), sms,
 	                                 reply, DLR_SMSC_FAIL);
             if (dlrmsg != NULL) {
                 bb_smscconn_receive(conn, dlrmsg);
@@ -867,6 +867,10 @@
 
 static int route_incoming_to_smsc(SMSCConn *conn, Msg *msg)
 {
+    /* sanity check */
+    if (!conn || !msg)
+        return 0;
+
     /* 
      * Check if we have any "reroute" rules to obey. Which means msg gets 
      * transported internally from MO to MT msg.

Attachment: pgp00000.pgp
Description: signature

Reply via email to