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.)
TryBot-Result: Gobot Gobot
Run-TryBot: Adam Langley
@@ -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
}
}
}
