Bug 924395 - Convert netmask for "ignore hosts" IPv6 address conversion in Gnome proxy settings. r=karlt
authorCarsten Sommer <cs_gon@yahoo.com>
Wed, 16 Oct 2013 08:27:59 -0400
changeset 164754 b936f0735ad8834880842b65661d047b5dcd6e83
parent 164753 f8e64e91e443b88c37eb632014ce17843304f7dd
child 164755 77a75238baa7f36a7138406e97852055b679734f
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs924395
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924395 - Convert netmask for "ignore hosts" IPv6 address conversion in Gnome proxy settings. r=karlt
toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
--- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
+++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
@@ -308,27 +308,33 @@ proxy_MaskIPv6Addr(PRIPv6Addr &addr, uin
     addr.pr_s6_addr32[2] = 0;
     addr.pr_s6_addr32[1] = 0;
     addr.pr_s6_addr32[0] = PR_htonl(
             PR_ntohl(addr.pr_s6_addr32[0]) & (~0L << (32 - mask_len)));
   }
 }
 
 static bool ConvertToIPV6Addr(const nsACString& aName,
-                                PRIPv6Addr* aAddr)
+                                PRIPv6Addr* aAddr, int32_t* aMask)
 {
   PRNetAddr addr;
   // try to convert hostname to IP
   if (PR_StringToNetAddr(PromiseFlatCString(aName).get(), &addr) != PR_SUCCESS)
     return false;
 
   // convert parsed address to IPv6
   if (addr.raw.family == PR_AF_INET) {
     // convert to IPv4-mapped address
     PR_ConvertIPv4AddrToIPv6(addr.inet.ip, aAddr);
+    if (aMask) {
+      if (*aMask <= 32)
+        *aMask += 96;
+      else
+        return false;
+    }
   } else if (addr.raw.family == PR_AF_INET6) {
     // copy the address
     memcpy(aAddr, &addr.ipv6.ip, sizeof(PRIPv6Addr));
   } else {
     return false;
   }
   
   return true;
@@ -363,18 +369,18 @@ static bool HostIgnoredByProxy(const nsA
     }
     --slash;
   } else {
     slash = end;
   }
 
   nsDependentCSubstring ignoreStripped(start, slash);
   PRIPv6Addr ignoreAddr, hostAddr;
-  if (!ConvertToIPV6Addr(ignoreStripped, &ignoreAddr) ||
-      !ConvertToIPV6Addr(aHost, &hostAddr))
+  if (!ConvertToIPV6Addr(ignoreStripped, &ignoreAddr, &mask) ||
+      !ConvertToIPV6Addr(aHost, &hostAddr, NULL))
     return false;
 
   proxy_MaskIPv6Addr(ignoreAddr, mask);
   proxy_MaskIPv6Addr(hostAddr, mask);
   
   return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
 }