mirror of https://github.com/docker/docs.git
Fix expending buffer in StdCopy
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
This commit is contained in:
parent
7727c817fb
commit
e4aaacc235
|
@ -108,12 +108,13 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
|
||||||
|
|
||||||
// Retrieve the size of the frame
|
// Retrieve the size of the frame
|
||||||
frameSize = int(binary.BigEndian.Uint32(buf[StdWriterSizeIndex : StdWriterSizeIndex+4]))
|
frameSize = int(binary.BigEndian.Uint32(buf[StdWriterSizeIndex : StdWriterSizeIndex+4]))
|
||||||
|
Debugf("framesize: %d", frameSize)
|
||||||
|
|
||||||
// Check if the buffer is big enough to read the frame.
|
// Check if the buffer is big enough to read the frame.
|
||||||
// Extend it if necessary.
|
// Extend it if necessary.
|
||||||
if frameSize+StdWriterPrefixLen > bufLen {
|
if frameSize+StdWriterPrefixLen > bufLen {
|
||||||
Debugf("Extending buffer cap.")
|
Debugf("Extending buffer cap by %d (was %d)", frameSize+StdWriterPrefixLen-bufLen+1, len(buf))
|
||||||
buf = append(buf, make([]byte, frameSize-len(buf)+1)...)
|
buf = append(buf, make([]byte, frameSize+StdWriterPrefixLen-bufLen+1)...)
|
||||||
bufLen = len(buf)
|
bufLen = len(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue