ssh/terminal: stop using ENABLE_LINE_INPUT
ReadConsole does not read more than 254 bytes when ENABLE_LINE_INPUT is enabled. Fixes golang/go#36071 Change-Id: If5c160404b855387a80f1d57638aac3f2db1a097 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/212377 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
committed by
Alex Brainman
parent
61a87790db
commit
6d4e4cb37c
@@ -947,6 +947,10 @@ func readPasswordLine(reader io.Reader) ([]byte, error) {
|
|||||||
n, err := reader.Read(buf[:])
|
n, err := reader.Read(buf[:])
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
switch buf[0] {
|
switch buf[0] {
|
||||||
|
case '\b':
|
||||||
|
if len(ret) > 0 {
|
||||||
|
ret = ret[:len(ret)-1]
|
||||||
|
}
|
||||||
case '\n':
|
case '\n':
|
||||||
return ret, nil
|
return ret, nil
|
||||||
case '\r':
|
case '\r':
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ func ReadPassword(fd int) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
old := st
|
old := st
|
||||||
|
|
||||||
st &^= (windows.ENABLE_ECHO_INPUT)
|
st &^= (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT)
|
||||||
st |= (windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
|
st |= (windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_PROCESSED_INPUT)
|
||||||
if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
|
if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user