JDK-6789865 : Java Plugin isInNet implementation returns incorrect value in some cases
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u4,6u11,6-pool
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows,windows_2003,windows_xp
  • CPU: x86
  • Submitted: 2009-01-02
  • Updated: 2010-12-03
  • Resolved: 2009-05-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u12-revFixed 7Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
There is a problem in the Java plug-in when using an automatic configuration script (.pac file) to determine the address of an HTTP proxy. This problem is related to bug ID 6338075 (Java Plugin's isInNet implementation should support partial octet subnets).  
  
This bug is fixed in Java 6.0, however there are still some cases in Java 6.0 where the isInNet function returns an incorrect result when using partial octet subnets. 
  
The following implementation of the FindProxyForURL function demonstrates the issue: 
  
 function FindProxyForURL(url,host) { 
 if (isInNet("209.249.1.141", "209.249.112.0", "255.255.240.0" )) { 
      return "PROXY proxyhost1:80"; 
  } else { 
      return "PROXY proxyhost2:80"; 
  } 

When using the above code in the .pac file, the browser will use proxyhost2 as the HTTP proxy to download the html pages (as 209.249.1.141 does not belong to the 209.249.112.0 network considering the 255.255.240.0 mask). The Java plugin however uses proxyhost1 to download the applets. The java implementation of the isInNet function returns in this case true although it should return false. 
  
In the following cases everything works OK (in the first case proxyhost1 is correctly used, in the second case proxyhost2 is correctly used): 
 
 function FindProxyForURL(url,host) { 
 if (isInNet("209.249.113.141", "209.249.112.0", "255.255.240.0" )) { 
      return "PROXY proxyhost1:80"; 
  } else { 
      return "PROXY proxyhost2:80"; 
  } 
 
 function FindProxyForURL(url,host) { 
 if (isInNet("209.249.49.141", "209.249.112.0", "255.255.240.0" )) { 
      return "PROXY proxyhost1:80"; 
  } else { 
      return "PROXY proxyhost2:80"; 
  } 
  
The problems seems to appear only if the AND operation on the mask and ipaddress returns 0. (in the first example above: 240 & 1 = 0, as a result the isInNet function returns the wrong value).

Comments
EVALUATION I did reproduce this bug in JRE 6u12, both new plugin and old plugin, will fix it in 6u14.
09-01-2009