You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2014/07/17 20:12:46 UTC
svn commit: r1611421 - in
/hadoop/common/branches/branch-2/hadoop-common-project: ./ hadoop-common/
hadoop-common/src/ hadoop-common/src/main/java/
hadoop-common/src/main/java/org/apache/hadoop/security/alias/
hadoop-common/src/test/java/org/apache/had...
Author: omalley
Date: Thu Jul 17 18:12:45 2014
New Revision: 1611421
URL: http://svn.apache.org/r1611421
Log:
HADOOP-10733. Fix potential null dereference in CredShell. (Ted Yu via
omalley)
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/ (props changed)
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/ (props changed)
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (contents, props changed)
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/ (props changed)
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/ (props changed)
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
Propchange: hadoop/common/branches/branch-2/hadoop-common-project/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-common-project:r1611419
Propchange: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-common-project/hadoop-common:r1611419
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1611421&r1=1611420&r2=1611421&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Thu Jul 17 18:12:45 2014
@@ -30,6 +30,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-10732. Fix locking in credential update. (Ted Yu via omalley)
+ HADOOP-10733. Fix potential null dereference in CredShell. (Ted Yu via
+ omalley)
+
OPTIMIZATIONS
BUG FIXES
Propchange: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt:r1611419
Propchange: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-common-project/hadoop-common/src:r1611419
Propchange: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java:r1611419
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java?rev=1611421&r1=1611420&r2=1611421&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java Thu Jul 17 18:12:45 2014
@@ -373,12 +373,12 @@ public class CredentialShell extends Con
char[] newPassword2 = c.readPassword("Enter password again: ");
noMatch = !Arrays.equals(newPassword1, newPassword2);
if (noMatch) {
- Arrays.fill(newPassword1, ' ');
+ if (newPassword1 != null) Arrays.fill(newPassword1, ' ');
c.format("Passwords don't match. Try again.%n");
} else {
cred = newPassword1;
}
- Arrays.fill(newPassword2, ' ');
+ if (newPassword2 != null) Arrays.fill(newPassword2, ' ');
} while (noMatch);
return cred;
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java?rev=1611421&r1=1611420&r2=1611421&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredShell.java Thu Jul 17 18:12:45 2014
@@ -128,6 +128,22 @@ public class TestCredShell {
}
@Test
+ public void testPromptForCredentialWithEmptyPasswd() throws Exception {
+ String[] args1 = {"create", "credential1", "--provider",
+ "jceks://file" + tmpDir + "/credstore.jceks"};
+ ArrayList<String> passwords = new ArrayList<String>();
+ passwords.add(null);
+ passwords.add("p@ssw0rd");
+ int rc = 0;
+ CredentialShell shell = new CredentialShell();
+ shell.setConf(new Configuration());
+ shell.setPasswordReader(new MockPasswordReader(passwords));
+ rc = shell.run(args1);
+ assertEquals(outContent.toString(), -1, rc);
+ assertTrue(outContent.toString().contains("Passwords don't match"));
+ }
+
+ @Test
public void testPromptForCredential() throws Exception {
String[] args1 = {"create", "credential1", "--provider",
"jceks://file" + tmpDir + "/credstore.jceks"};
@@ -142,7 +158,7 @@ public class TestCredShell {
assertEquals(0, rc);
assertTrue(outContent.toString().contains("credential1 has been successfully " +
"created."));
-
+
String[] args2 = {"delete", "credential1", "--provider",
"jceks://file" + tmpDir + "/credstore.jceks"};
rc = shell.run(args2);
@@ -162,7 +178,7 @@ public class TestCredShell {
public char[] readPassword(String prompt) {
if (passwords.size() == 0) return null;
String pass = passwords.remove(0);
- return pass.toCharArray();
+ return pass == null ? null : pass.toCharArray();
}
@Override