reject invalid offset/length in map storage

This commit is contained in:
Jarek Kowalski
2018-07-19 15:01:53 -08:00
parent a91c46e9b4
commit 6af6914b40

View File

@@ -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