From 6af6914b40cc5401ac8953f681fef74ac05cd49f Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Thu, 19 Jul 2018 15:01:53 -0800 Subject: [PATCH] reject invalid offset/length in map storage --- internal/storagetesting/map.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/storagetesting/map.go b/internal/storagetesting/map.go index 40e94e209..e3bda18a7 100644 --- a/internal/storagetesting/map.go +++ b/internal/storagetesting/map.go @@ -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