[PATCH]ppg push - crashing bug trusted-pi/no user

"Bas A. Schulte" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

[reposted as per Stipe's request to use unified diffs and appr. subject 
line]

here are two patches that solve crashing bug 
http://bugs.kannel.org/view_bug_page.php?f_id=8

First is gw/wap_push_ppg.c, in pap_request_thread. When there's no user 
involved in the request (with a trusted-pi), wapbox gets a bus error 
upon handling a push request. pap_request_thread now checks for this and 
uses the default smsc-id for routing the message.

Second is in gw/wap_push_ppg_pushuser.c, 
wap_push_ppg_pushuser_smsc_id_get references a NULL user when 
user_find_by_username returns NULL.

Patches attached.

Cheers,

Bas.
wap_push_ppg.c.patch (application/octet-stream, 1.9 KB)
--- wap_push_ppg.c	Thu Mar 20 12:57:29 2003
+++ wap_push_ppg.c.patched	Thu Mar 20 12:31:17 2003
@@ -837,14 +837,33 @@
             /* check if we have an explicit routing information */
             retos = http_cgi_variable(cgivars, "smsc");
             if (retos == NULL) {
-                /* get the push user specific smsc routing */
-                smsc_id = wap_push_ppg_pushuser_smsc_id_get(username);
-                /* if there was no user specific, then set the ppg global */
-                smsc_id = smsc_id ? 
+
+            	/* No explicit routing specified in request */
+
+            	/* If there's a user involved with this request, find smsc-id for this user, else */
+            	/* (no user involved) get the default smsc-id. */
+
+					if (username == NULL || (octstr_str_compare(username,"") == 0)) {
+						/* No user associated with request, use default smsc-id */
+						smsc_id = smsc_id ? 
                     smsc_id : (ppg_default_smsc ? octstr_duplicate(ppg_default_smsc) : NULL);
+
+                    if (smsc_id == NULL) {
+                    		debug("wap.push.ppg", 0, "PPG: no user associated with request, no default smsc-id");
+                    } else {
+                    		debug("wap.push.ppg", 0, "PPG: no user associated with request, using default smsc-id");
+                    }
+					} else {	
+						 /* get the push user specific smsc routing */
+						 smsc_id = wap_push_ppg_pushuser_smsc_id_get(username);
+						 /* if there was no user specific, then set the ppg global */
+						 smsc_id = smsc_id ? 
+							  smsc_id : (ppg_default_smsc ? octstr_duplicate(ppg_default_smsc) : NULL);
+               }
             } else {
                 smsc_id = octstr_duplicate(retos);
             }
+
             ppg_event->u.Push_Message.push_headers = 
                 http_header_duplicate(push_headers);
             ppg_event->u.Push_Message.push_data = octstr_duplicate(push_data);
wap_push_ppg_pushuser.c.patch (application/octet-stream, 441 B)
--- wap_push_ppg_pushuser.c	Thu Mar 20 12:57:39 2003
+++ wap_push_ppg_pushuser.c.patched	Thu Mar 20 12:26:36 2003
@@ -316,10 +316,17 @@
     Octstr *smsc_id;
 
     u = user_find_by_username(username);
+
+	if (u == NULL) {
+		/* No user found... */
+		return (NULL);
+	}
+
     if ((smsc_id = forced_smsc(u)) != NULL)
         return octstr_duplicate(smsc_id);
 
     smsc_id = default_smsc(u);
+
     return octstr_duplicate(smsc_id);
 }
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.