add size check to chunk datalen

This commit is contained in:
Joel Wetzell
2026-05-20 17:44:01 -05:00
parent 145c13a976
commit 2df4cd56f7
+4
View File
@@ -30,6 +30,10 @@ func DecodeChunk(bytes []byte) (chunks.Chunk, error) {
HasSubchunks: has_subchunks,
}
if len(bytes) < 4+int(header.DataLen) {
return chunks.Chunk{}, errors.New("chunk data length is greater than the number of bytes")
}
chunk_data := bytes[4 : 4+header.DataLen]
return chunks.Chunk{