mirror of
https://github.com/kopia/kopia.git
synced 2026-03-13 03:36:34 -04:00
reject invalid offset/length in map storage
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -28,6 +29,10 @@ func (s *mapStorage) GetBlock(ctx context.Context, id string, offset, length int
|
||||
return data, nil
|
||||
}
|
||||
|
||||
if int(offset) > len(data) || offset < 0 {
|
||||
return nil, errors.New("invalid offset")
|
||||
}
|
||||
|
||||
data = data[offset:]
|
||||
if int(length) > len(data) {
|
||||
return data, nil
|
||||
|
||||
Reference in New Issue
Block a user