aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgutmet <me.git@gutmet.org>2020-04-27 22:49:23 +0200
committergutmet <me.git@gutmet.org>2020-04-27 22:49:23 +0200
commitd2cf77fb993f832021d442fa144a357bb510b5a8 (patch)
treecebf57327de79529a980c8b67fc40df5f194c2e9
parentade1c6e06e46ce80ff77cd2c74ca2079934f39d6 (diff)
downloadlaymanshex-d2cf77fb993f832021d442fa144a357bb510b5a8.tar.gz
bugfix: make sure that even unnamed parts at the end can be read
* seek does not fail, even if the pointer is beyond the end of the file
-rw-r--r--laymanshex.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/laymanshex.go b/laymanshex.go
index bece35c..04bffd2 100644
--- a/laymanshex.go
+++ b/laymanshex.go
@@ -406,7 +406,12 @@ func getValues(descr fileDescription, binpath string) map[string]string {
optPanic("failed to open binary", err)
for i, part := range descr.parts {
if part.name == "" {
- _, err = f.Seek(part.handling.bytes, 1)
+ if i == len(descr.parts)-1 {
+ throwaway := make([]byte, part.handling.bytes)
+ _, err = f.Read(throwaway)
+ } else {
+ _, err = f.Seek(part.handling.bytes, 1)
+ }
optPanic(seekErr(i, part.name, err), err)
} else {
vals[part.name] = part.handling.readFrom(f, descr.byteOrder)