Author: sebb
Date: Sun Mar 20 15:34:07 2011
New Revision: 1083470

URL: http://svn.apache.org/viewvc?rev=1083470&view=rev
Log:
Record unknown file type; avoid array index OOBE

Modified:
    
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java

Modified: 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
URL: 
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java?rev=1083470&r1=1083469&r2=1083470&view=diff
==============================================================================
--- 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
 (original)
+++ 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
 Sun Mar 20 15:34:07 2011
@@ -148,7 +148,7 @@ public class MLSxEntryParser extends FTP
             else if ("type".equals(factname)) {
                     Integer intType = TYPE_TO_INT.get(valueLowerCase);
                     if (intType == null) {
-                        // TODO System.out.println(factvalue+ "? in "+entry);
+                        file.setType(FTPFile.UNKNOWN_TYPE);
                     } else {
                         file.setType(intType.intValue());
                     }
@@ -163,8 +163,12 @@ public class MLSxEntryParser extends FTP
                     int off = factvalue.length()-4; // only parse last 3 digits
                     for(int i=1; i<=3; i++){
                         int ch = factvalue.charAt(off+i)-'0';
-                        for(int p : UNIX_PERMS[ch]) {
-                            file.setPermission(UNIX_GROUPS[i-1], p, true);
+                        if (ch >= 0 && ch <= 7) { // Check it's valid octal
+                            for(int p : UNIX_PERMS[ch]) {
+                                file.setPermission(UNIX_GROUPS[i-1], p, true);
+                            }
+                        } else {
+                            // TODO should this cause failure, or can it be 
reported somehow?
                         }
                     }
                     file.setUser(factvalue);


Reply via email to