mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Fixed malformed offset bug in readOffsets
This commit is contained in:
parent
eb5d1ae1a4
commit
55aa864cac
2 changed files with 9 additions and 0 deletions
|
|
@ -61,6 +61,11 @@ func TestUnmarshalBinary(t *testing.T) {
|
|||
cr: []byte(";0\x000\v00000"), //";0000000"
|
||||
expected: "reading offsets from official roaring format: offset incomplete: len=10",
|
||||
},
|
||||
{ // Checks for incomplete offset in readOffsets
|
||||
cr: []byte(":0\x000\x03\x00\x00\x00000000000000" +
|
||||
"\x00"), //:0000000000000
|
||||
expected: "reading offsets from official roaring format: offset incomplete: len=1",
|
||||
},
|
||||
}
|
||||
|
||||
for _, crash := range confirmedCrashers {
|
||||
|
|
|
|||
|
|
@ -4527,6 +4527,10 @@ func readOffsets(b *Bitmap, data []byte, pos int, keyN uint32) error {
|
|||
|
||||
citer, _ := b.Containers.Iterator(0)
|
||||
for i, buf := 0, data[pos:]; i < int(keyN); i, buf = i+1, buf[4:] {
|
||||
// Verify the offset is fully formed
|
||||
if len(buf) < 4 {
|
||||
return fmt.Errorf("offset incomplete: len=%d", len(buf))
|
||||
}
|
||||
offset := binary.LittleEndian.Uint32(buf[0:4])
|
||||
// Verify the offset is within the bounds of the input data.
|
||||
if int(offset) >= len(data) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue