Browse code

core: safety check for append_branch() when called with no uri and no msg

- uri or msg parameter must be given, otherwise the new address cannot
be set
- get_redirects() from uac_redirect can execute this function with both
parameters invalid in case of invalid contact, reported by Javi
Gallart

(cherry picked from commit 2c4ed5922a2322f3b5059f6264884acfb5dec97f)
(cherry picked from commit a90e73327cccb5259af08cbf93f2a1b793a0ca2e)

Daniel-Constantin Mierla authored on 05/02/2015 10:26:34
Showing 1 changed files
... ...
@@ -341,6 +341,11 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
341 341
 
342 342
 	/* if not parameterized, take current uri */
343 343
 	if (uri==0 || uri->len==0 || uri->s==0) {
344
+		if(msg==NULL) {
345
+			LM_ERR("no new uri and no msg to take r-uri\n");
346
+			ser_error = E_INVALID_PARAMS;
347
+			return -1;
348
+		}
344 349
 		if (msg->new_uri.s)
345 350
 			luri = msg->new_uri;
346 351
 		else