فهرست منبع

modules/sipcapture: Fixed crash in case contact was "*"
(cherry picked from commit 11ca33836fdd33d7c3d36c4f1acc6c6782edfb5d)

Marius Zbihlei 13 سال پیش
والد
کامیت
c618a65e19
1فایلهای تغییر یافته به همراه18 افزوده شده و 7 حذف شده
  1. 18 7
      modules/sipcapture/sipcapture.c

+ 18 - 7
modules/sipcapture/sipcapture.c

@@ -188,7 +188,7 @@ static str type_column 		= str_init("type");
 static str node_column 		= str_init("node");  
 static str msg_column 		= str_init("msg");   
 static str capture_node 	= str_init("homer01");     	
-
+static str star_contact		= str_init("*");
 
 int raw_sock_desc = -1; /* raw socket used for ip packets */
 unsigned int raw_sock_children = 1;
@@ -1176,12 +1176,23 @@ static int sip_capture(struct sip_msg *msg, char *s1, char *s2)
 
               cb = (contact_body_t*)msg->contact->parsed;
 
-              if(cb && cb->contacts) {
-                  if(parse_uri( cb->contacts->uri.s, cb->contacts->uri.len, &contact)<0){
-                        LOG(L_ERR, "ERROR: do_action: bad contact dropping"" packet\n");
-                        return -1;
-                  }
-              }
+              if(cb) {
+            	    if (cb->contacts) {
+			if(parse_uri( cb->contacts->uri.s, cb->contacts->uri.len, &contact)<0){
+                		LOG(L_ERR, "ERROR: do_action: bad contact dropping"" packet\n");
+                 	    	return -1;
+                  	}
+              	    } else {
+              		if(cb->star){ /* in the case Contact is "*" */
+			    memset(&contact, 0, sizeof(contact));
+			    contact.user.s =  star_contact.s;
+			    contact.user.len = star_contact.len;
+			} else {
+			    LOG(L_NOTICE,"Invalid contact\n");
+			    memset(&contact, 0, sizeof(contact));
+			}
+		    }
+	    }
         }
 
 	/* get header x-cid: */