Browse code

core: fix an error in check_via_address, reported from Mojtaba, mespio at gmail dot com

- fix an error in check_via_address, reported from Mojtaba, mespio at gmail dot com
- use the same logic for IPv4 string comparison as for IPv6
- the old comparison could return true for e.g. via="192.168.1.1", src="192.1.1.100"
- the new logic is also faster for the trivial case with different string length

Henning Westerholt authored on 30/12/2018 00:17:15
Showing 1 changed files
... ...
@@ -179,7 +179,7 @@ static int check_via_address(struct ip_addr* ip, str *name,
179 179
 				LM_CRIT("invalid Via host name\n");
180 180
 				return -1;
181 181
 			}
182
-			if (strncmp(name->s, s, name->len)==0)
182
+			if (len==name->len&&(strncmp(name->s, s, name->len)==0))
183 183
 				return 0;
184 184
 		}
185 185
 	}else{