Fix dump of extra page.
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Thu, 27 Mar 2014 11:03:48 +0000 (08:03 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Thu, 27 Mar 2014 11:07:19 +0000 (08:07 -0300)
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 <cascardo@cascardo.eti.br>
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;
                        }
                                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);
        }
        free(page);
        close(out);