mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-01 05:58:29 +00:00
8321131: Console read line with zero out should zero out underlying buffer in JLine
Reviewed-by: iris, alanb, jlahoda
This commit is contained in:
parent
155abc576a
commit
bd04f91e91
@ -67,6 +67,9 @@ public class JdkConsoleProviderImpl implements JdkConsoleProvider {
|
||||
* public Console class.
|
||||
*/
|
||||
private static class JdkConsoleImpl implements JdkConsole {
|
||||
private final Terminal terminal;
|
||||
private volatile LineReader jline;
|
||||
|
||||
@Override
|
||||
public PrintWriter writer() {
|
||||
return terminal.writer();
|
||||
@ -110,6 +113,8 @@ public class JdkConsoleProviderImpl implements JdkConsoleProvider {
|
||||
return jline.readLine(fmt.formatted(args), '\0').toCharArray();
|
||||
} catch (EndOfFileException eofe) {
|
||||
return null;
|
||||
} finally {
|
||||
jline.getBuffer().zeroOut();
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,9 +133,6 @@ public class JdkConsoleProviderImpl implements JdkConsoleProvider {
|
||||
return terminal.encoding();
|
||||
}
|
||||
|
||||
private final Terminal terminal;
|
||||
private volatile LineReader jline;
|
||||
|
||||
public JdkConsoleImpl(Terminal terminal) {
|
||||
this.terminal = terminal;
|
||||
}
|
||||
|
||||
@ -84,4 +84,8 @@ public interface Buffer {
|
||||
|
||||
void copyFrom(Buffer buffer);
|
||||
|
||||
// JDK specific modification
|
||||
default void zeroOut() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
*/
|
||||
package jdk.internal.org.jline.reader.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import jdk.internal.org.jline.reader.Buffer;
|
||||
@ -369,4 +370,10 @@ public class BufferImpl implements Buffer
|
||||
g1 += l;
|
||||
}
|
||||
}
|
||||
|
||||
// JDK specific modification
|
||||
@Override
|
||||
public void zeroOut() {
|
||||
Arrays.fill(buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user