From d2cf77fb993f832021d442fa144a357bb510b5a8 Mon Sep 17 00:00:00 2001 From: gutmet Date: Mon, 27 Apr 2020 22:49:23 +0200 Subject: [PATCH] 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 --- laymanshex.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)