Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 512cd87

Browse files
committed
8322417: Console read line with zero out should zero out when throwing exception
8322772: Clean up code after JDK-8322417 Reviewed-by: mbaesken Backport-of: 2f917bff5cbb71dccd70960f563ca1a05d109fda
1 parent 75f52ea commit 512cd87

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,17 @@ public char[] readPassword(String fmt, Object ... args) {
119119
else
120120
ioe.addSuppressed(x);
121121
}
122-
if (ioe != null)
122+
if (ioe != null) {
123+
Arrays.fill(passwd, ' ');
124+
try {
125+
if (reader instanceof LineReader lr) {
126+
lr.zeroOut();
127+
}
128+
} catch (IOException x) {
129+
// ignore
130+
}
123131
throw ioe;
132+
}
124133
}
125134
pw.println();
126135
}

0 commit comments

Comments
 (0)