summaryrefslogtreecommitdiff
path: root/lib/binstruct/structs.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-12 16:24:30 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-12 16:24:30 -0600
commit54ba669b644f13c158fcbbde76943543eaf66e0a (patch)
treeecfeda5df17525782cdbe1e40f5c1330b9832237 /lib/binstruct/structs.go
parent2f28e21aef9be5755fa5f175bb74c9aa6548d1cc (diff)
lib/btrfs: Fuzz the Node parser
Diffstat (limited to 'lib/binstruct/structs.go')
-rw-r--r--lib/binstruct/structs.go5
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 {