From 23ca4151b18fe6ef3f8022e19a2e2a03f240880a Mon Sep 17 00:00:00 2001 From: manugarg Date: Tue, 7 Dec 2010 19:53:25 +0530 Subject: [PATCH 1/4] freeaddrinfo should be called with 'result' rather than 'ai', as 'ai' can be NULL after the for loop. Thanks to 'honkman42' for reporting the bug and suggesting the fix. (Issue: http://goo.gl/HpIeA) --- src/pacparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacparser.c b/src/pacparser.c index fca87a8a..bea4a53e 100644 --- a/src/pacparser.c +++ b/src/pacparser.c @@ -118,7 +118,7 @@ resolve_host(const char *hostname, char *ipaddr_list, int max_results) if (ipaddr_list[0] == '\0') sprintf(ipaddr_list, "%s", ipaddr); else sprintf(ipaddr_list, "%s;%s", ipaddr_list, ipaddr); } - freeaddrinfo(ai); + freeaddrinfo(result); #ifdef _WIN32 WSACleanup(); #endif From c24f0b2078eddcb0fbdb69e4401ca95a076dba80 Mon Sep 17 00:00:00 2001 From: manugarg Date: Tue, 7 Dec 2010 20:22:02 +0530 Subject: [PATCH 2/4] Delete 'dist' directory during cleanup. --- src/Makefile.win32 | 1 + src/pymod/Makefile.win32 | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile.win32 b/src/Makefile.win32 index 74259e40..eb6a8e96 100644 --- a/src/Makefile.win32 +++ b/src/Makefile.win32 @@ -74,3 +74,4 @@ clean: del /F pacparser.dll *.lib pacparser.def pacparser.exp pacparser.o pactester.exe libpacparser.a $(MAKE) -C spidermonkey -f Makefile.win32 clean cd pymod && setup.py clean + if exist dist rmdir /s /q dist diff --git a/src/pymod/Makefile.win32 b/src/pymod/Makefile.win32 index 6c1645f6..8606619d 100644 --- a/src/pymod/Makefile.win32 +++ b/src/pymod/Makefile.win32 @@ -65,5 +65,5 @@ dist: build copy ..\..\INSTALL dist\INSTALL.txt clean: - if exist pacparser_py.o del pacparser_py.o - if exist _pacparser.pyd del _pacparser.pyd + del /F pacparser_py.o _pacparser.pyd + if exist dist rmdir /s /q dist From 395d839245ee5a61c7e0c657c1056aef4a33781a Mon Sep 17 00:00:00 2001 From: manugarg Date: Tue, 7 Dec 2010 22:44:12 +0530 Subject: [PATCH 3/4] Truncate ipaddr_list before sprinting strings into it. (See issue caused by not doing this: http://goo.gl/ww69d) --- src/pacparser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pacparser.c b/src/pacparser.c index bea4a53e..7dc23845 100644 --- a/src/pacparser.c +++ b/src/pacparser.c @@ -98,6 +98,9 @@ resolve_host(const char *hostname, char *ipaddr_list, int max_results) char ipaddr[INET6_ADDRSTRLEN]; int error; + // Truncate ipaddr_list to an empty string. + ipaddr_list[0] = '\0'; + #ifdef _WIN32 // On windows, we need to initialize the winsock dll first. WSADATA WsaData; From d9045bcb3fc1d242ff1938876acc98d3ab98e891 Mon Sep 17 00:00:00 2001 From: manugarg Date: Tue, 7 Dec 2010 23:28:13 +0530 Subject: [PATCH 4/4] = Fix a bug in test data. Set local ip using '-c' while testing for end of the script. (Issue: http://goo.gl/eoo0F) = Remove one duplicate test. --- tests/proxy.pac | 3 --- tests/testdata | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/proxy.pac b/tests/proxy.pac index 50fa3455..866eb9a9 100644 --- a/tests/proxy.pac +++ b/tests/proxy.pac @@ -29,9 +29,6 @@ function FindProxyForURL(url, host) { if (/^https:\/\/.*$/.test(url)) return "secureUrl"; - if (isInNet(myIpAddress(), '192.0.0.0', '255.0.0.0')) - return '192.0.0.0'; - if (isInNet(myIpAddress(), '10.10.0.0', '255.255.0.0')) return '10.10.0.0'; diff --git a/tests/testdata b/tests/testdata index 4a46815a..de9a9efe 100644 --- a/tests/testdata +++ b/tests/testdata @@ -1,5 +1,5 @@ # Command Line Parameters|Expected Result --u http://www.google.co.in|END-OF-SCRIPT +-c 0.0.0.0 -u http://www.google.co.in|END-OF-SCRIPT -e -u http://www.google.com|dnsResolveEx defined -u http://host1|plainhost/.manugarg.com -u http://www1.manugarg.com|plainhost/.manugarg.com @@ -7,5 +7,4 @@ -u http://www.google.com|isResolvable -u http://www.notresolvabledomainXXX.com|isNotResolvable -u https://www.somehost.com|secureUrl --c 192.168.101.1 -u http://www.somehost.com|192.0.0.0 -c 10.10.100.112 -u http://www.somehost.com|10.10.0.0