Skip to content

Commit f16f5d2

Browse files
committed
From Andrew Pritchard:
use io.ReadFull in fcgi implementation in some cases, particularly UNIX domain sockets, pipes, or other things with 4k (page-sized) buffers, FCGI requests longer than that buffer size are truncated by io.Reader.Read returning fewer bytes than the full slice size. Fix this by using io.ReadFull
1 parent 61b0bff commit f16f5d2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fcgi.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,20 @@ func (s *Server) handleFcgiConnection(fd io.ReadWriteCloser) {
245245
break
246246
}
247247
content := make([]byte, h.ContentLength)
248-
br.Read(content)
248+
_, err = io.ReadFull(br, content)
249+
if err != nil {
250+
s.Logger.Println("FCGI Error", err.String())
251+
break
252+
}
249253

250254
//read padding
251255
if h.PaddingLength > 0 {
252256
padding := make([]byte, h.PaddingLength)
253-
br.Read(padding)
257+
_, err = io.ReadFull(br, padding)
258+
if err != nil {
259+
s.Logger.Println("FCGI Error", err.String())
260+
break
261+
}
254262
}
255263

256264
switch h.Type {

0 commit comments

Comments
 (0)