Browse Source

http2/h2c: Add missing error check

Before this change, error returned by `io.ReadFull` was silently
ignored

Signed-off-by: Michal Rostecki <mrostecki@suse.de>
Change-Id: I6a4604f0c0172a4b951fa4fc99ee83c6ba2ac8d7
Reviewed-on: https://go-review.googlesource.com/c/153137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Michal Rostecki 7 năm trước cách đây
mục cha
commit
6105869963
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      http2/h2c/h2c.go

+ 3 - 0
http2/h2c/h2c.go

@@ -118,6 +118,9 @@ func initH2CWithPriorKnowledge(w http.ResponseWriter) (net.Conn, error) {
 
 	buf := make([]byte, len(expectedBody))
 	n, err := io.ReadFull(rw, buf)
+	if err != nil {
+		return nil, fmt.Errorf("could not read from the buffer: %s", err)
+	}
 
 	if string(buf[:n]) == expectedBody {
 		c := &rwConn{