diff --git a/src/libty/firmware.c b/src/libty/firmware.c index 9c193c1..75ead3a 100644 --- a/src/libty/firmware.c +++ b/src/libty/firmware.c @@ -140,6 +140,8 @@ static ssize_t read_file(int64_t offset, uint8_t *buf, size_t len, void *udata) return ty_error(TY_ERROR_SYSTEM, "fseek('%s') failed: %s", ctx->filename, strerror(errno)); } } + + ctx->offset = offset; } r = (ssize_t)fread(buf, 1, len, ctx->fp); @@ -166,7 +168,7 @@ static ssize_t read_memory(int64_t offset, uint8_t *buf, size_t len, void *udata size_t copy_len = _HS_MIN((size_t)ctx->len - (size_t)offset, (size_t)len); memcpy(buf, ctx->mem + offset, copy_len); - ctx->offset += (int64_t)copy_len; + ctx->offset = offset + (int64_t)copy_len; return (ssize_t)copy_len; }