From 54ba669b644f13c158fcbbde76943543eaf66e0a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 12 Jul 2022 16:24:30 -0600 Subject: lib/btrfs: Fuzz the Node parser --- lib/binstruct/structs.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/binstruct/structs.go') diff --git a/lib/binstruct/structs.go b/lib/binstruct/structs.go index 72fd5e5..9bc556c 100644 --- a/lib/binstruct/structs.go +++ b/lib/binstruct/structs.go @@ -9,6 +9,8 @@ import ( "reflect" "strconv" "strings" + + "git.lukeshu.com/btrfs-progs-ng/lib/binstruct/binutil" ) type End struct{} @@ -70,6 +72,9 @@ type structField struct { } func (sh structHandler) Unmarshal(dat []byte, dst reflect.Value) (int, error) { + if err := binutil.NeedNBytes(dat, sh.Size); err != nil { + return 0, fmt.Errorf("struct %q %w", sh.name, err) + } var n int for i, field := range sh.fields { if field.skip { -- cgit v1.2.3-2-g168b