Skip to content

Commit

Permalink
8322417: Console read line with zero out should zero out when throwin…
Browse files Browse the repository at this point in the history
…g exception

Backport-of: 2f917bf
  • Loading branch information
GoeLin authored and RealCLanger committed Dec 29, 2023
1 parent 694be7d commit b3c96ba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ public char[] readPassword(String fmt, Object ... args) {
else
ioe.addSuppressed(x);
}
if (ioe != null)
if (ioe != null) {
java.util.Arrays.fill(passwd, ' ');
try {
if (reader instanceof LineReader lr) {
lr.zeroOut();
}
} catch (IOException x) {
// ignore
}
throw ioe;
}
}
pw.println();
}
Expand Down

0 comments on commit b3c96ba

Please sign in to comment.