Ver Fonte

Merge remote branch 'origin/sr_3.0'

The dst_uri fix (see FlySpray#37) and kamctl.

* origin/sr_3.0:
  core: avoid non-null 0-length dst_uri,  ruris and path
  tm: fake_req dst_uri and ruri copy fix
  utils/kamctl: removed unsupported commands to manage lcr gateways and routes
Andrei Pelinescu-Onciul há 15 anos atrás
pai
commit
08811a87aa
5 ficheiros alterados com 17 adições e 34 exclusões
  1. 6 0
      modules/tm/t_reply.c
  2. 8 4
      parser/msg_parser.c
  3. 3 0
      sip_msg_clone.c
  4. 0 15
      utils/kamctl/kamctl.8
  5. 0 15
      utils/kamctl/kamctl.base

+ 6 - 0
modules/tm/t_reply.c

@@ -784,6 +784,9 @@ int fake_req(struct sip_msg *faked_req,
 		memcpy( faked_req->dst_uri.s, shmem_msg->dst_uri.s,
 			faked_req->dst_uri.len);
 		faked_req->dst_uri.s[faked_req->dst_uri.len]=0;
+	}else{
+		/* in case len==0, but shmem_msg->dst_uri.s!=0 (extra safety) */
+		faked_req->dst_uri.s = 0;
 	}
 	/* new_uri can change -- make a private copy */
 	if (shmem_msg->new_uri.s!=0 && shmem_msg->new_uri.len!=0) {
@@ -796,6 +799,9 @@ int fake_req(struct sip_msg *faked_req,
 		memcpy( faked_req->new_uri.s, shmem_msg->new_uri.s,
 			faked_req->new_uri.len);
 		faked_req->new_uri.s[faked_req->new_uri.len]=0;
+	}else{
+		/* in case len==0, but shmem_msg->new_uri.s!=0  (extra safety)*/
+		faked_req->new_uri.s = 0;
 	}
 	if(uac) setbflagsval(0, uac->branch_flags);
 	else setbflagsval(0, 0);

+ 8 - 4
parser/msg_parser.c

@@ -751,12 +751,14 @@ int set_dst_uri(struct sip_msg* msg, str* uri)
 {
 	char* ptr;
 
-	if (!msg || !uri) {
+	if (unlikely(!msg || !uri)) {
 		LOG(L_ERR, "set_dst_uri: Invalid parameter value\n");
 		return -1;
 	}
 
-	if (msg->dst_uri.s && (msg->dst_uri.len >= uri->len)) {
+	if (unlikely(uri->len == 0)) {
+		reset_dst_uri(msg);
+	}else if (msg->dst_uri.s && (msg->dst_uri.len >= uri->len)) {
 		memcpy(msg->dst_uri.s, uri->s, uri->len);
 		msg->dst_uri.len = uri->len;
 	} else {
@@ -788,12 +790,14 @@ int set_path_vector(struct sip_msg* msg, str* path)
 {
 	char* ptr;
 
-	if (!msg || !path) {
+	if (unlikely(!msg || !path)) {
 		LM_ERR("invalid parameter value\n");
 		return -1;
 	}
 
-	if (msg->path_vec.s && (msg->path_vec.len >= path->len)) {
+	if (unlikely(path->len == 0)) {
+		reset_path_vector(msg);
+	} else if (msg->path_vec.s && (msg->path_vec.len >= path->len)) {
 		memcpy(msg->path_vec.s, path->s, path->len);
 		msg->path_vec.len = path->len;
 	} else {

+ 3 - 0
sip_msg_clone.c

@@ -520,6 +520,9 @@ struct sip_msg*  sip_msg_shm_clone( struct sip_msg *org_msg, int *sip_msg_len,
 	new_msg->add_rm = 0;
 	new_msg->body_lumps = 0;
 	new_msg->reply_lump = 0;
+	/* zero *uri.s, in case len is 0 but org_msg->*uris!=0 (just to be safe)*/
+	new_msg->new_uri.s = 0;
+	new_msg->dst_uri.s = 0;
 	/* new_uri */
 	if (org_msg->new_uri.s && org_msg->new_uri.len)
 	{

+ 0 - 15
utils/kamctl/kamctl.8

@@ -57,26 +57,11 @@ Grant user membership(s) (*)
 .TP 16
 .I  Least cost routes (lcr) managment command:
 .TP             
-.B lcr show 
-Show gateways and routes tables
-.TP
 .B lcr dump
 Show in memory gateways and routes tables
 .TP
 .B lcr reload 
 Reload lcr gateways and routes
-.TP
-.B lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <flags> <tag> <strip> <weight> <hostname> <ping>
-Add a gateway with flags, tag, strip, weight, hostname, and ping (flags, tag, strip, weight, hostname, and ping are optional)
-.TP
-.B lcr rmgw <gw_name> 
-Delete a gateway
-.TP
-.B lcr addroute <prefix> <from> <grp_id> <prio>
-Add a route ( use '' to match anything in <from> )
-.TP
-.B lcr rmroute <prefix> <from> <grp_id> <prio>
-Delete a route
 
 .TP 16
 .I Carrierroute tables('cr') managment commands:

+ 0 - 15
utils/kamctl/kamctl.base

@@ -362,23 +362,8 @@ usage_lcr() {
 	mecho " -- command 'lcr' - manage least cost routes (lcr)"
 	echo
 cat <<EOF
-   * IP addresses must be entered in dotted quad format e.g. 1.2.3.4   *
-   * <uri_scheme> and <transport> must be entered in integer or text,  *
-   * e.g. transport '2' is identical to transport 'tcp'.               *
-   *   scheme: 1=sip, 2=sips;   transport: 1=udp, 2=tcp, 3=tls, 4=sctp *
-   * Examples:  lcr addgw level3 1.2.3.4 5080 sip tcp 1                *
-   *            lcr addroute +1 '' 1 1                                 *
- lcr show .......... show gateways and routes tables
  lcr dump .......... show in memory gateways and routes tables
  lcr reload ........ reload lcr gateways and routes
- lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <flags> <tag> <strip> <weight> <hostname> <ping>
-           ......... add a gateway with flags, tag, strip, weight, hostname, and ping
-           ......... (flags, tag, strip, weight, hostname, and ping are optional)
- lcr rmgw <gw_name> delete a gateway
- lcr addroute <prefix> <from> <grp_id> <prio>
-           ......... add a route ( use '' to match anything in <from> )
- lcr rmroute <prefix> <from> <grp_id> <prio>
-           ......... delete a route
 EOF
 }
 USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_lcr"