Fix dump of extra page.
[cascardo/bootimg.git] / bootimg.c
index 77758c2..9ce6fb8 100644 (file)
--- 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);