mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Implemented previous fixes not present
This commit is contained in:
parent
8c264d9249
commit
2df44eecfd
2 changed files with 7 additions and 1 deletions
|
|
@ -30,7 +30,7 @@ func TestUnmarshalBinary(t *testing.T) {
|
|||
{
|
||||
cr : []byte("<0\x000\x00\x00\x00\x00000000000000" +
|
||||
"0"), //"<000000000000000"
|
||||
expected : "unmarshaling as pilosa roaring: too big",
|
||||
expected : "unmarshaling as pilosa roaring: Maximum operation size exceeded",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3944,6 +3944,7 @@ func (op *op) WriteTo(w io.Writer) (n int64, err error) {
|
|||
}
|
||||
|
||||
var minOpSize = 13
|
||||
var maxBatchSize = uint64(1<<59)
|
||||
|
||||
// UnmarshalBinary decodes data into an op.
|
||||
func (op *op) UnmarshalBinary(data []byte) error {
|
||||
|
|
@ -3961,6 +3962,11 @@ func (op *op) UnmarshalBinary(data []byte) error {
|
|||
_, _ = h.Write(data[0:9])
|
||||
|
||||
if op.typ > 1 {
|
||||
// This ensures that in doing 13+op.value*8, the max int won't be exceeded and a wrap around case
|
||||
// (resulting in a negative value) won't occur in the slice indexing while writing
|
||||
if op.value > maxBatchSize {
|
||||
return fmt.Errorf("Maximum operation size exceeded")
|
||||
}
|
||||
if len(data) < int(13+op.value*8) {
|
||||
return fmt.Errorf("op data truncated - expected %d, got %d", 13+op.value*8, len(data))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue