зеркало из https://github.com/golang/term.git
ssh/terminal: consume data before checking for an error.
According to the io.Reader docs, Alex had it right the first time. (See discussion on https://golang.org/cl/25355.) Change-Id: Ib6fb9dfb99009e034263574e82d7e9d4828df38f Reviewed-on: https://go-review.googlesource.com/35242 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: Adam Langley <agl@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
Родитель
038bd0bb6d
Коммит
efcab1a52e
13
terminal.go
13
terminal.go
|
@ -930,12 +930,6 @@ func readPasswordLine(reader io.Reader) ([]byte, error) {
|
|||
|
||||
for {
|
||||
n, err := reader.Read(buf[:])
|
||||
if err != nil {
|
||||
if err == io.EOF && len(ret) > 0 {
|
||||
return ret, nil
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
if n > 0 {
|
||||
switch buf[0] {
|
||||
case '\n':
|
||||
|
@ -945,6 +939,13 @@ func readPasswordLine(reader io.Reader) ([]byte, error) {
|
|||
default:
|
||||
ret = append(ret, buf[0])
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF && len(ret) > 0 {
|
||||
return ret, nil
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче