mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 02:48:48 +03:00
Fixed panic due to 0-length buffers being passed to io.CopyBuffer
This commit is contained in:
parent
6352c9054a
commit
53635ba538
1 changed files with 5 additions and 2 deletions
|
@ -253,7 +253,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
|
|||
}
|
||||
|
||||
func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
|
||||
buf := bufferPool.Get()
|
||||
buf := bufferPool.Get().([]byte)
|
||||
defer bufferPool.Put(buf)
|
||||
|
||||
if rp.FlushInterval != 0 {
|
||||
|
@ -268,7 +268,10 @@ func (rp *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue