Merge pull request #1052 from versity/ben/chunk_reader_crash

fix: prevent panic with malformed chunk encoding
This commit is contained in:
Ben McClelland
2025-02-03 09:07:17 -08:00
committed by GitHub
+4 -1
View File
@@ -230,11 +230,14 @@ const (
maxHeaderSize = 1024
)
// Theis returns the chunk payload size, signature, data start offset, and
// This returns the chunk payload size, signature, data start offset, and
// error if any. See the AWS documentation for the chunk header format. The
// header[0] byte is expected to be the first byte of the chunk size here.
func (cr *ChunkReader) parseChunkHeaderBytes(header []byte) (int64, string, int, error) {
stashLen := len(cr.stash)
if stashLen > maxHeaderSize {
return 0, "", 0, errInvalidChunkFormat
}
if cr.stash != nil {
tmp := make([]byte, maxHeaderSize)
copy(tmp, cr.stash)