Assuming the read() call does not return zero and the result is less
than len, the current implementation will overwrite the data already
read in buf which doesn't seem correct.
With this patch, subsequent calls to read() within the loop will now no
longer overwrite the existing contents of buf.
Signed-off-by: Marcus Prebble <marcus.prebble@axis.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
mtd->mtd_num, seek);
while (rd < len) {
- ret = read(fd, buf, len);
+ ret = read(fd, buf + rd, len - rd);
if (ret < 0)
return sys_errmsg("cannot read %d bytes from mtd%d (eraseblock %d, offset %d)",
- len, mtd->mtd_num, eb, offs);
+ len - rd, mtd->mtd_num, eb, offs + rd);
rd += ret;
}