[sr-dev] IPv4 and IPv6 binary comparison

Klaus Darilion klaus.mailinglists at pernau.at
Thu Apr 28 14:31:53 CEST 2011



Am 28.04.2011 11:53, schrieb Iñaki Baz Castillo:
> 2011/4/28 Daniel-Constantin Mierla <daniel at kamailio.org>:
>> Btw, when was the idea that IP comparison is string comparison thrown here,
>> I missed any email?!? To be sure the comparison is done right, then the
>> string with the IPs have to be converted to binary and the results compared.
> 
> The point is that IPv4 comparisons are valid as a pure string
> comparison. Note that being strict, the following IPv4 is not valid:
> 
>   "1.2.3.04"

but it works. E.g

INVITE sip:0900123455 at 1.2.3.004

works with Kamailio. Thus when making string based checks you do not
have to rely on valid or not. Thus, I never would do IPv4 comparisons
with "string" comparisons if one of the values is user provided, e.g.

if ($rd == "1.2.3.4") {
  sl_send_reply("403","not allowed");
  exit;
}

would fail to detect the above request.

regards
Klaus



More information about the sr-dev mailing list