United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6789865 Java Plugin isInNet implementation returns incorrect value in some cases
JDK-6789865 : Java Plugin isInNet implementation returns incorrect value in some cases

Details
Type:
Bug
Submit Date:
2009-01-02
Status:
Closed
Updated Date:
2010-12-03
Project Name:
JDK
Resolved Date:
2009-05-15
Component:
deploy
OS:
windows_2003,windows_xp,windows
Sub-Component:
plugin
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u4,6u11,6-pool
Fixed Versions:
6u14 (b01)

Related Reports
Backport:
Backport:
Relates:
Relates:
Relates:

Sub Tasks

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.
                                     
2009-01-09



Hardware and Software, Engineered to Work Together