Commit 53635ba5 authored by Leonard Hecker's avatar Leonard Hecker

Fixed panic due to 0-length buffers being passed to io.CopyBuffer

parent 6352c905
...@@ -253,7 +253,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request, ...@@ -253,7 +253,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
} }
func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) { func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
buf := bufferPool.Get() buf := bufferPool.Get().([]byte)
defer bufferPool.Put(buf) defer bufferPool.Put(buf)
if rp.FlushInterval != 0 { if rp.FlushInterval != 0 {
...@@ -268,7 +268,10 @@ func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) { ...@@ -268,7 +268,10 @@ func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
dst = mlw dst = mlw
} }
} }
io.CopyBuffer(dst, src, buf.([]byte))
// `CopyBuffer` only uses `buf` up to it's length and
// panics if it's 0 => Extend it's length up to it's capacity.
io.CopyBuffer(dst, src, buf[:cap(buf)])
} }
// skip these headers if they already exist. // skip these headers if they already exist.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment