frontend: fix uninitialized buffer (#41)

This commit is contained in:
Yuhui Xu 2021-09-26 13:26:07 -05:00 committed by GitHub
parent 2166d73b3d
commit 6481e7cc8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -55,11 +55,11 @@ func batchRequest(servers []string, endpoint string, command string) []string {
}
buf := make([]byte, 65536)
_, err = io.ReadFull(response.Body, buf)
n, err := io.ReadFull(response.Body, buf)
if err != nil && err != io.ErrUnexpectedEOF {
ch <- channelData{i, err.Error()}
} else {
ch <- channelData{i, string(buf)}
ch <- channelData{i, string(buf[:n])}
}
}(url, i)
}

View File

@ -21,9 +21,9 @@ func whois(s string) string {
conn.Write([]byte(s + "\r\n"))
buf := make([]byte, 65536)
_, err = io.ReadFull(conn, buf)
n, err := io.ReadFull(conn, buf)
if err != nil && err != io.ErrUnexpectedEOF {
return err.Error()
}
return string(buf)
return string(buf[:n])
}