Move cpio end trailer detection to the cpio code
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 18 Apr 2012 08:38:29 +0000 (11:38 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 18 Apr 2012 08:38:29 +0000 (11:38 +0300)
- The fsm shouldn't know any archive format specifics, detect the trailer
  from rpmcpioHeaderRead() and signal EOF through CPIOERR_HDR_TRAILER
  instead.

lib/cpio.c
lib/fsm.c

index 045b56e..c7a8bdf 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <rpm/rpmio.h>
 #include <rpm/rpmlog.h>
+#include <rpm/rpmstring.h>
 
 #include "lib/cpio.h"
 
@@ -303,6 +304,9 @@ int rpmcpioHeaderRead(rpmcpio_t cpio, char ** path, struct stat * st)
     rc = rpmcpioReadPad(cpio);
     cpio->fileend = cpio->offset + st->st_size;
 
+    if (!rc && rstreq(*path, CPIO_TRAILER))
+       rc = CPIOERR_HDR_TRAILER;
+
     return rc;
 }
 
index cd653e1..bba02c1 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1723,8 +1723,10 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
         rc = rpmcpioHeaderRead(archive, &(fsm->path), &(fsm->sb));
 
        /* Detect and exit on end-of-payload. */
-       if (!rc && rstreq(fsm->path, CPIO_TRAILER))
+       if (rc == CPIOERR_HDR_TRAILER) {
+           rc = 0;
            break;
+       }
 
        if (rc) break;