volkertb / proxy-vole

Automatically exported from code.google.com/p/proxy-vole
0 stars 0 forks source link

isInNet() PAC function throws a NumberFormatException when passed an FQDN for the host #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The PacScriptMethods.isInNet() function doesn't resolve host names passed into 
it but tries to parse them as IP addresses instead. This causes the script to 
throw a NumberFormatException when the function is used with a host name in a 
PAC script.

The fix I have used in my environment is to change the function to the 
following:
public boolean isInNet(String host, String pattern, String mask) {
    String resolved = dnsResolve(host);
    if ((resolved == null) || (resolved.length() == 0)) return false;
    long lhost = parseIpAddressToLong(resolved);
    long lpattern = parseIpAddressToLong(pattern);
    long lmask = parseIpAddressToLong(mask);
    boolean result = (lhost & lmask) == lpattern; 
    return result;
}

Original issue reported on code.google.com by elpoll...@gmail.com on 24 Jul 2012 at 2:26

GoogleCodeExporter commented 9 years ago
Hi,
I have taken over your fix. It is available in the newest version.

Thanks for reporting this.

Have fun,
- Rossi

Original comment by rosstaus...@googlemail.com on 27 Jul 2012 at 9:22

GoogleCodeExporter commented 9 years ago
That's brilliant!

Thanks very much.

Original comment by elpoll...@gmail.com on 30 Jul 2012 at 8:27