6996192: Console.readPassword race: input echo off must be prior to writing prompt
To turn off echo before prompt Reviewed-by: alanb
This commit is contained in:
parent
3cda6b5fd0
commit
05a3d3acb6
@ -308,17 +308,29 @@ public final class Console implements Flushable
|
|||||||
char[] passwd = null;
|
char[] passwd = null;
|
||||||
synchronized (writeLock) {
|
synchronized (writeLock) {
|
||||||
synchronized(readLock) {
|
synchronized(readLock) {
|
||||||
if (fmt.length() != 0)
|
|
||||||
pw.format(fmt, args);
|
|
||||||
try {
|
try {
|
||||||
echoOff = echo(false);
|
echoOff = echo(false);
|
||||||
passwd = readline(true);
|
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
throw new IOError(x);
|
throw new IOError(x);
|
||||||
|
}
|
||||||
|
IOError ioe = null;
|
||||||
|
try {
|
||||||
|
if (fmt.length() != 0)
|
||||||
|
pw.format(fmt, args);
|
||||||
|
passwd = readline(true);
|
||||||
|
} catch (IOException x) {
|
||||||
|
ioe = new IOError(x);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
echoOff = echo(true);
|
echoOff = echo(true);
|
||||||
} catch (IOException xx) {}
|
} catch (IOException x) {
|
||||||
|
if (ioe == null)
|
||||||
|
ioe = new IOError(x);
|
||||||
|
else
|
||||||
|
ioe.addSuppressed(x);
|
||||||
|
}
|
||||||
|
if (ioe != null)
|
||||||
|
throw ioe;
|
||||||
}
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user