Pay attention to NULL returns from rpmcpioOpen()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 18 Apr 2012 09:48:58 +0000 (12:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 18 Apr 2012 09:48:58 +0000 (12:48 +0300)
- The archive interface might actually want separate new + open,
  but for now just flag an internal error on NULL return on archive open.

lib/fsm.c

index 155ff47..ce8a202 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1695,13 +1695,13 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
               rpmpsm psm, char ** failedFile)
 {
     FSM_t fsm = fsmNew(FSM_PKGINSTALL, ts, te, fi, failedFile);
-    rpmcpio_t archive = NULL;
+    rpmcpio_t archive = rpmcpioOpen(cfd, O_RDONLY);
     struct stat * st = &fsm->sb;
     int saveerrno = errno;
     int rc = 0;
 
-    if (!rc)
-        archive = rpmcpioOpen(cfd, O_RDONLY);
+    if (archive == NULL)
+       rc = CPIOERR_INTERNAL;
 
     /* transaction id used for temporary path suffix while installing */
     rasprintf(&fsm->suffix, ";%08x", (unsigned)rpmtsGetTid(ts));
@@ -1933,11 +1933,11 @@ int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
               rpm_loff_t * archiveSize, char ** failedFile)
 {
     FSM_t fsm = fsmNew(FSM_PKGBUILD, ts, te, fi, failedFile);;
-    rpmcpio_t archive = NULL;
+    rpmcpio_t archive = rpmcpioOpen(cfd, O_WRONLY);
     int rc = 0;
 
-    if (!rc)
-        archive = rpmcpioOpen(cfd, O_WRONLY);
+    if (archive == NULL)
+       rc = CPIOERR_INTERNAL;
 
     while (!rc) {
        fsmReset(fsm);