FYI: remove extra File.createTempFile() security checks

Gary Benson gbenson@redhat.com
Fri Jul 14 14:42:00 GMT 2006


Hi all,

This commit quells a pair of security checks in File.createTempFile()
that other VMs do not perform.

Cheers,
Gary
-------------- next part --------------
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 115439)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2006-07-14  Gary Benson  <gbenson@redhat.com>
+
+	* java/io/File.java (internalExists): New method.
+	(exists): Use internalExists.
+	(internalIsDirectory): New method.
+	(isDirectory): Use internalIsDirectory.
+	(createTempFile): Use internalExists and internalIsDirectory.
+
 2006-07-13  Bryce McKinlay  <mckinlay@redhat.com>
 
 	* interpret.cc (_Jv_InterpMethod::run): Don't SAVE_PC for fdiv.
Index: java/io/File.java
===================================================================
--- java/io/File.java	(revision 115439)
+++ java/io/File.java	(working copy)
@@ -259,6 +259,15 @@
       return path.equalsIgnoreCase(other.path);
   }
 
+  /*
+   * This method tests whether or not the file represented by the
+   * object actually exists on the filesystem.
+   */
+  private boolean internalExists()
+  {
+    return _access (EXISTS);
+  }
+  
   /**
    * This method tests whether or not the file represented by the object
    * actually exists on the filesystem.
@@ -270,7 +279,7 @@
   public boolean exists()
   {
     checkRead();
-    return _access (EXISTS);
+    return internalExists();
   }
 
   /**
@@ -685,6 +694,15 @@
    */
   public native boolean isAbsolute();
 
+  /*
+   * This method tests whether or not the file represented by this
+   * object is a directory.
+   */
+  private boolean internalIsDirectory()
+  {
+    return _stat (DIRECTORY);
+  }
+  
   /**
    * This method tests whether or not the file represented by this object
    * is a directory.  In order for this method to return <code>true</code>,
@@ -698,7 +716,7 @@
   public boolean isDirectory()
   {
     checkRead();
-    return _stat (DIRECTORY);
+    return internalIsDirectory();
   }
 
   /**
@@ -1069,10 +1087,10 @@
           throw new IOException("Cannot determine system temporary directory"); 
 	
         directory = new File(dirname);
-        if (!directory.exists())
+        if (!directory.internalExists())
           throw new IOException("System temporary directory "
                                 + directory.getName() + " does not exist.");
-        if (!directory.isDirectory())
+        if (!directory.internalIsDirectory())
           throw new IOException("System temporary directory "
                                 + directory.getName()
                                 + " is not really a directory.");


More information about the Java-patches mailing list