codegooglecom / libproxy

Automatically exported from code.google.com/p/libproxy
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Crash on Mac OS X 10.6 when bypass proxy contains 169.254/16 (works fine on 10.7 and 10.8 though) #194

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download libproxy 0.4.11 and patch it using the patch from Issue 183
2. Build 32-bit libproxy.dylib with settings CMAKE_BUILD_TYPE=Debug and 
CMAKE_OSX_ARCHITECTURES=i386 and 
3. Use libproxy.dylib and it will crash when using the Mac OS X default bypass 
proxies "*.local, 169.254/16". When changing to the following it works though 
"*.local, 169.254.0.0/16"

I think it is getaddrinfo in line 74 of ignore_ip.cpp where it goes wrong. I've 
got a feeling that getaddrinfo in 10.6 doesn't like "169.254/16" while it works 
in 10.7 and 10.8.

Please provide any additional information below.

Below follows an excerpt of a gdb run on 10.6.8.

libproxy is a great product so it would be even better if it worked flawlessly 
on Mac OS X 10.6 too!
Best,
Sven

(gdb) b ignore_ip.cpp:74
No source file named ignore_ip.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (ignore_ip.cpp:74) pending.
(gdb) c
Continuing.
Reading symbols for shared libraries .. done
Breakpoint 1 at 0x13ddea0a: file ignore_ip.cpp, line 74.
Pending breakpoint 1 - "ignore_ip.cpp:74" resolved
[Switching to process 2534 thread 0x1203]

Breakpoint 1, sockaddr_from_string (ip=@0xb00e2868) at ignore_ip.cpp:74
74      if (getaddrinfo(ip.c_str(), NULL, &flags, &info) != 0 || !info) return 
result;
(gdb) p flags
$1 = {
  ai_flags = 4, 
  ai_family = 0, 
  ai_socktype = 0, 
  ai_protocol = 0, 
  ai_addrlen = 2953717736, 
  ai_canonname = 0x9a6ddb40 "?U\b?\002?É\004$?3?\001", 
  ai_addr = 0x313d50, 
  ai_next = 0xb00e27de
}
Current language:  auto; currently c++
(gdb) p info
$2 = (addrinfo *) 0x0
(gdb) p ip.c_str()
$3 = 0x313d5c "*.local"
(gdb) c
Continuing.

Breakpoint 1, sockaddr_from_string (ip=@0xb00e2868) at ignore_ip.cpp:74
74      if (getaddrinfo(ip.c_str(), NULL, &flags, &info) != 0 || !info) return 
result;
(gdb) p ip.c_str()
$4 = 0x101d6c "169.254/16"
(gdb) p flags
$5 = {
  ai_flags = 4, 
  ai_family = 0, 
  ai_socktype = 0, 
  ai_protocol = 0, 
  ai_addrlen = 2953717736, 
  ai_canonname = 0x9a6ddb40 "?U\b?\002?É\004$?3?\001", 
  ai_addr = 0x101d60, 
  ai_next = 0xb00e27de
}
(gdb) p info
$6 = (addrinfo *) 0x0
(gdb) n
74      if (getaddrinfo(ip.c_str(), NULL, &flags, &info) != 0 || !info) return 
result;
(gdb) n
ip_ignore_extension::ignore (this=0x313da0, url=@0xb00e2bc8, 
ignore=@0xb00e2968) at ignore_ip.cpp:135
135         if (ignore.find('/') != string::npos)
(gdb) n
137             ign_ip = sockaddr_from_string(ignore.substr(0, ignore.find('/')));
(gdb) n

Breakpoint 1, sockaddr_from_string (ip=@0xb00e2870) at ignore_ip.cpp:74
74      if (getaddrinfo(ip.c_str(), NULL, &flags, &info) != 0 || !info) return 
result;
(gdb) n
74      if (getaddrinfo(ip.c_str(), NULL, &flags, &info) != 0 || !info) return 
result;
(gdb) n
ip_ignore_extension::ignore (this=0x313da0, url=@0xb00e2bc8, 
ignore=@0xb00e2968) at ignore_ip.cpp:139
139             uint32_t cidr = 0;
(gdb) n
140             string mask = ignore.substr(ignore.find('/') + 1);
(gdb) n
142             if (mask.find('.') != string::npos)
(gdb) n
150                 if (sscanf(mask.c_str(), "%d", &cidr) == 1)
(gdb) n
151                     net_ip = sockaddr_from_cidr(ign_ip->sa_family, cidr);
(gdb) n

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000001
0x13ddef4b in ip_ignore_extension::ignore (this=0x313da0, url=@0xb00e2bc8, 
ignore=@0xb00e2968) at ignore_ip.cpp:151
151                     net_ip = sockaddr_from_cidr(ign_ip->sa_family, cidr);
(gdb) bt
#0  0x13ddef4b in ip_ignore_extension::ignore (this=0x313da0, url=@0xb00e2bc8, 
ignore=@0xb00e2968) at ignore_ip.cpp:151
#1  0x13db63a6 in libproxy::proxy_factory::is_ignored (this=0x3138c0, 
realurl=@0xb00e2bc8, ignore=@0xb00e2be8) at proxy.cpp:298
#2  0x13dba2f9 in libproxy::proxy_factory::get_config (this=0x3138c0, 
realurl=@0xb00e2bc8, config=@0xb00e2bf0, ignore=@0xb00e2be8) at proxy.cpp:264
#3  0x13dbaa8e in libproxy::proxy_factory::get_proxies (this=0x3138c0, 
realurl=@0xb00e2d58) at proxy.cpp:206
#4  0x13dbb4cc in px_proxy_factory_get_proxies (self=0x3138c0, url=0x806800 
"http://www.doremir.com") at proxy.cpp:463
#5  0x2007334e in ?? ()
#6  0x22a97d75 in ?? ()
#7  0x23405868 in ?? ()
#8  0x235bbe5c in ?? ()
#9  0x2032a995 in ?? ()
#10 0x20950f13 in ?? ()
(gdb) 

Original issue reported on code.google.com by sven.emt...@doremir.com on 30 May 2013 at 8:44

GoogleCodeExporter commented 9 years ago
A long time has passed, but here is a patch I made for ignore_ip.cpp to solve 
the problem for 0.4.11.

Original comment by sven.emt...@doremir.com on 4 Jun 2014 at 1:46

Attachments: