From 629f196118682cd6f6cf5358315fc1e3d7041862 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 27 Mar 2014 08:03:48 -0300 Subject: [PATCH] Fix dump of extra page. On the last page, just the remaining data is dump, ignoring any padding. However, a page is dumped like in every loop, resulting in an extra page on the output file. Just dump an entire page when it isn't the last one. Signed-off-by: Thadeu Lima de Souza Cascardo --- bootimg.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bootimg.c b/bootimg.c index 77758c2..9ce6fb8 100644 --- a/bootimg.c +++ b/bootimg.c @@ -48,13 +48,14 @@ static int dump(int fd, size_t len, int pgsz, char *fname) if (r != len) goto out; } + } else { + r = read(fd, page, pgsz); + if (r != pgsz) + goto out; + r = write(out, page, pgsz); + if (r != pgsz) + goto out; } - r = read(fd, page, pgsz); - if (r != pgsz) - goto out; - r = write(out, page, pgsz); - if (r != pgsz) - goto out; } free(page); close(out); -- 2.20.1