Commit cc6c155e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4e0c9ad3
...@@ -50,6 +50,7 @@ import ( ...@@ -50,6 +50,7 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree" "lab.nexedi.com/kirr/neo/go/zodb/btree"
pickle "github.com/kisielk/og-rek" pickle "github.com/kisielk/og-rek"
"github.com/johncgriffin/overflow"
"./internal/pycompat" "./internal/pycompat"
) )
...@@ -374,7 +375,10 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err ...@@ -374,7 +375,10 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
// find out whole blk len via inspecting tail chunk // find out whole blk len via inspecting tail chunk
tailStart := offv[len(offv)-1] tailStart := offv[len(offv)-1]
tailChunk := chunktab[tailStart] tailChunk := chunktab[tailStart]
blklen := tailStart + int32(len(tailChunk.data)) // XXX overflow? blklen, ok := overflow.Add32(tailStart, int32(len(tailChunk.data)))
if !ok {
return nil, 0, fmt.Errorf("invalid data: blklen overflow")
}
// whole buffer initialized as 0 + tail_chunk // whole buffer initialized as 0 + tail_chunk
blkdata := make([]byte, blklen) blkdata := make([]byte, blklen)
...@@ -385,12 +389,12 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err ...@@ -385,12 +389,12 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
for _, start := range offv[:len(offv)-1] { for _, start := range offv[:len(offv)-1] {
chunk := chunktab[start] chunk := chunktab[start]
if !(start >= stop) { // verify chunks don't overlap if !(start >= stop) { // verify chunks don't overlap
return nil, 0, fmt.Errorf("!(start >= stop)") // XXX return nil, 0, fmt.Errorf("invalid data: chunks overlap")
} }
if !(start + int32(len(chunk.data)) <= int32(len(blkdata))) { // XXX overflow? stop, ok = overflow.Add32(start, int32(len(chunk.data)))
return nil, 0, fmt.Errorf("blkdata overrun") // XXX if !(ok && stop <= blklen) {
return nil, 0, fmt.Errorf("invalid data: blkdata overrun")
} }
stop = start + int32(len(chunk.data)) // XXX overflow?
copy(blkdata[start:], chunk.data) copy(blkdata[start:], chunk.data)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment