HADOOP-10507. FsShell setfacl can throw ArrayIndexOutOfBoundsException when no perm is specified. Contributed by Stephen Chu and Sathish Gurram.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1609503 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-07-10 16:57:17 +00:00
parent a53262605a
commit 112145727e
3 changed files with 17 additions and 1 deletions

View File

@ -398,6 +398,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-10781. Unportable getgrouplist() usage breaks FreeBSD (Dmitry HADOOP-10781. Unportable getgrouplist() usage breaks FreeBSD (Dmitry
Sivachenko via Colin Patrick McCabe) 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 Release 2.5.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -278,7 +278,7 @@ public class AclEntry {
} }
if (includePermission) { if (includePermission) {
if (split.length < index) { if (split.length <= index) {
throw new HadoopIllegalArgumentException("Invalid <aclSpec> : " throw new HadoopIllegalArgumentException("Invalid <aclSpec> : "
+ aclStr); + aclStr);
} }

View File

@ -83,6 +83,19 @@ public class TestAclCommands {
"", "/path" })); "", "/path" }));
} }
@Test
public void testSetfaclValidationsWithoutPermissions() throws Exception {
List<AclEntry> parsedList = new ArrayList<AclEntry>();
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 @Test
public void testMultipleAclSpecParsing() throws Exception { public void testMultipleAclSpecParsing() throws Exception {
List<AclEntry> parsedList = AclEntry.parseAclSpec( List<AclEntry> parsedList = AclEntry.parseAclSpec(