diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index fd53e10638f..148b6e58725 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -15,6 +15,9 @@ Release 2.6.0 - UNRELEASED HADOOP-10781. Unportable getgrouplist() usage breaks FreeBSD (Dmitry Sivachenko via Colin Patrick McCabe) + HADOOP-10507. FsShell setfacl can throw ArrayIndexOutOfBoundsException when + no perm is specified. (Stephen Chu and Sathish Gurram via cnauroth) + Release 2.5.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclEntry.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclEntry.java index 0ce7fbfe9dc..b65b7a0b438 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclEntry.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/AclEntry.java @@ -278,7 +278,7 @@ public class AclEntry { } if (includePermission) { - if (split.length < index) { + if (split.length <= index) { throw new HadoopIllegalArgumentException("Invalid : " + aclStr); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java index b14cd37c49d..cb6f560c95f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java @@ -83,6 +83,19 @@ public class TestAclCommands { "", "/path" })); } + @Test + public void testSetfaclValidationsWithoutPermissions() throws Exception { + List parsedList = new ArrayList(); + try { + parsedList = AclEntry.parseAclSpec("user:user1:", true); + } catch (IllegalArgumentException e) { + } + assertTrue(parsedList.size() == 0); + assertFalse("setfacl should fail with less arguments", + 0 == runCommand(new String[] { "-setfacl", "-m", "user:user1:", + "/path" })); + } + @Test public void testMultipleAclSpecParsing() throws Exception { List parsedList = AclEntry.parseAclSpec(