From 510726494ac5478a114daac9a6ab48eaca0f7bc7 Mon Sep 17 00:00:00 2001 From: Vishal Nayak Date: Wed, 7 Nov 2018 17:10:08 -0500 Subject: [PATCH] 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 --- vault/barrier_aes_gcm.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vault/barrier_aes_gcm.go b/vault/barrier_aes_gcm.go index 0f44ef886..8ddae2898 100644 --- a/vault/barrier_aes_gcm.go +++ b/vault/barrier_aes_gcm.go @@ -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])