From 0fcb2a628cbacd7a3a0a3123354c7e7ce04d2be9 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Fri, 11 Feb 2022 22:06:25 +0000 Subject: [PATCH] server/storage/wal: fix oss-fuzz issue 44433 --- server/storage/wal/version.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/storage/wal/version.go b/server/storage/wal/version.go index e4c3c250057..07a441f6844 100644 --- a/server/storage/wal/version.go +++ b/server/storage/wal/version.go @@ -213,7 +213,12 @@ func visitEnumNumber(enum protoreflect.EnumDescriptor, number protoreflect.EnumN if err != nil { return err } - return visitEnumValue(enum.Values().Get(int(number)), visitor) + intNumber := int(number) + fields := enum.Values() + if intNumber >= fields.Len() || intNumber < 0 { + return fmt.Errorf("could not visit EnumNumber [%d]", intNumber) + } + return visitEnumValue(fields.Get(intNumber), visitor) } func visitEnumValue(enum protoreflect.EnumValueDescriptor, visitor Visitor) error {