diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 16:24:30 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-12 16:24:30 -0600 |
commit | 54ba669b644f13c158fcbbde76943543eaf66e0a (patch) | |
tree | ecfeda5df17525782cdbe1e40f5c1330b9832237 /lib/binstruct | |
parent | 2f28e21aef9be5755fa5f175bb74c9aa6548d1cc (diff) |
lib/btrfs: Fuzz the Node parser
Diffstat (limited to 'lib/binstruct')
-rw-r--r-- | lib/binstruct/structs.go | 5 |
1 files changed, 5 insertions, 0 deletions
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 { |