hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r788549 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java
Date Thu, 25 Jun 2009 23:40:05 GMT
Author: szetszwo
Date: Thu Jun 25 23:40:05 2009
New Revision: 788549

URL: http://svn.apache.org/viewvc?rev=788549&view=rev
Log:
HDFS-181. Validate src path in FSNamesystem.getFileInfo(..).  Contributed by Todd Lipcon

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=788549&r1=788548&r2=788549&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Jun 25 23:40:05 2009
@@ -35,6 +35,9 @@
     HDFS-195. Handle expired tokens when write pipeline is restablished.
     (Kan Zhang via rangadi)
 
+    HDFS-181. Validate src path in FSNamesystem.getFileInfo(..).  (Todd
+    Lipcon via szetszwo)
+
 Release 0.20.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=788549&r1=788548&r2=788549&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Thu
Jun 25 23:40:05 2009
@@ -1442,6 +1442,9 @@
    *         or null if file not found
    */
   FileStatus getFileInfo(String src) throws IOException {
+    if (!DFSUtil.isValidName(src)) {
+      throw new IOException("Invalid file name: " + src);
+    }
     if (isPermissionEnabled) {
       checkTraverse(src);
     }

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java?rev=788549&r1=788548&r2=788549&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java Thu Jun 25
23:40:05 2009
@@ -26,6 +26,7 @@
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.ipc.RemoteException;
 
 /**
  * This class tests the FileStatus API.
@@ -79,6 +80,15 @@
       FileStatus fileInfo = dfsClient.getFileInfo("/noSuchFile");
       assertTrue(fileInfo == null);
 
+      // make sure getFileInfo throws the appropriate exception for non-relative
+      // filenames
+      try {
+        FileStatus foo = dfsClient.getFileInfo("non-relative");
+        fail("getFileInfo for a non-relative path did not thro IOException");
+      } catch (RemoteException re) {
+        assertTrue(re.toString().contains("Invalid file name"));
+      }
+
       // create a file in home directory
       //
       Path file1 = new Path("filestatus.dat");



Mime
View raw message