Browse code

- safer handling of the 'received' Contact parameter

Jan Janak authored on 14/11/2004 22:30:32
Showing 1 changed files
... ...
@@ -166,10 +166,13 @@ int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, in
166 166
 	branches[nr_branches].len = uri_len;
167 167
 	branches[nr_branches].q = q;
168 168
 	
169
-	if (dst_uri) {
170
-		memcpy(branches[nr_branches].dst_uri, dst_uri, dst_uri_len);
171
-		branches[nr_branches].dst_uri[dst_uri_len] = 0;
172
-		branches[nr_branches].dst_uri_len = dst_uri_len;
169
+ 	if (dst_uri && dst_uri_len) {
170
+  		memcpy(branches[nr_branches].dst_uri, dst_uri, dst_uri_len);
171
+  		branches[nr_branches].dst_uri[dst_uri_len] = 0;
172
+  		branches[nr_branches].dst_uri_len = dst_uri_len;
173
+ 	} else {
174
+ 		branches[nr_branches].dst_uri[0] = '\0';
175
+ 		branches[nr_branches].dst_uri_len = 0;
173 176
 	}
174 177
 
175 178
 	nr_branches++;