[sr-dev] git:master:536736f2: lcr: remove excessive checks for the 'src_port' accuracy

Victor Seva linuxmaniac at torreviejawireless.org
Wed Aug 25 09:28:43 CEST 2021


Module: kamailio
Branch: master
Commit: 536736f2529f7554929f3aa6b74ac616c382bc6e
URL: https://github.com/kamailio/kamailio/commit/536736f2529f7554929f3aa6b74ac616c382bc6e

Author: Donat Zenichev <dzenichev at sipwise.com>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2021-08-25T09:28:38+02:00

lcr: remove excessive checks for the 'src_port' accuracy

Remove unneeded check for 'src_port' in:
- ki_from_any_gw_addr()
- ki_from_gw_addr()

Which makes no sense because 'src_port' is of type 'unsigned int',
and the check concerns whether it's less than 0 or not.

---

Modified: src/modules/lcr/lcr_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/536736f2529f7554929f3aa6b74ac616c382bc6e.diff
Patch: https://github.com/kamailio/kamailio/commit/536736f2529f7554929f3aa6b74ac616c382bc6e.patch

---

diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c
index 858352f2c7..57b4021ac9 100644
--- a/src/modules/lcr/lcr_mod.c
+++ b/src/modules/lcr/lcr_mod.c
@@ -3093,9 +3093,9 @@ static int ki_from_gw_addr(
 		return -1;
 	}
 
-	/* src_port set to 0 means we don't want to check it */
-	if((src_port < 0) || (src_port > 65535)) {
-		LM_ERR("invalid port parameter value %d\n", transport);
+	/* src_port set to 0 is allowed and means we don't want to check it */
+	if(src_port > 65535) {
+		LM_ERR("invalid port parameter value %d\n", src_port);
 		return -1;
 	}
 
@@ -3215,9 +3215,9 @@ static int ki_from_any_gw_addr(sip_msg_t *_m, str *addr_str, int transport, unsi
 		return -1;
 	}
 
-	/* src_port set to 0 means we don't want to check it */
-	if((src_port < 0) || (src_port > 65535)) {
-		LM_ERR("invalid port parameter value %d\n", transport);
+	/* src_port set to 0 is allowed and means we don't want to check it */
+	if(src_port > 65535) {
+		LM_ERR("invalid port parameter value %d\n", src_port);
 		return -1;
 	}
 




More information about the sr-dev mailing list