diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-10 23:49:07 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-11 00:44:30 -0600 |
commit | ad9ac6d07ce1819260c2b7f090fd4fe742c80d9f (patch) | |
tree | ab6a607ea8575382c978f07de943ccf6c077de7c /lib/binstruct/binutil/binutil.go | |
parent | 41ef03aabf8d6db4f926480fc5ddfec014e342d3 (diff) |
Fuzz btrfsitem, and by consequence improve binstruct errors
Diffstat (limited to 'lib/binstruct/binutil/binutil.go')
-rw-r--r-- | lib/binstruct/binutil/binutil.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/binstruct/binutil/binutil.go b/lib/binstruct/binutil/binutil.go new file mode 100644 index 0000000..684237f --- /dev/null +++ b/lib/binstruct/binutil/binutil.go @@ -0,0 +1,16 @@ +// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package binutil + +import ( + "fmt" +) + +func NeedNBytes(dat []byte, n int) error { + if len(dat) < n { + return fmt.Errorf("need at least %v bytes, only have %v", n, len(dat)) + } + return nil +} |