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
This commit is contained in:
gutmet 2020-04-27 22:49:23 +02:00
parent ade1c6e06e
commit d2cf77fb99

View File

@ -406,7 +406,12 @@ func getValues(descr fileDescription, binpath string) map[string]string {
optPanic("failed to open binary", err) optPanic("failed to open binary", err)
for i, part := range descr.parts { for i, part := range descr.parts {
if part.name == "" { 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) optPanic(seekErr(i, part.name, err), err)
} else { } else {
vals[part.name] = part.handling.readFrom(f, descr.byteOrder) vals[part.name] = part.handling.readFrom(f, descr.byteOrder)