Fix panic when storage value is nil (#5724)

* Fix panic when storage value is nil

* Ensure the value is at least of expected length

* Format correction

* Address review feedback
This commit is contained in:
Vishal Nayak 2018-11-07 17:10:08 -05:00 committed by Brian Kassouf
parent fa26beeaed
commit 510726494a
1 changed files with 5 additions and 0 deletions

View File

@ -708,6 +708,11 @@ func (b *AESGCMBarrier) Get(ctx context.Context, key string) (*Entry, error) {
return nil, nil
}
if len(pe.Value) < 4 {
b.l.RUnlock()
return nil, errors.New("invalid value")
}
// Verify the term
term := binary.BigEndian.Uint32(pe.Value[:4])