[PATCH] Fix the order of arguments in archive read callback and archive closing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



libarchive read callback returns number of bytes, but Fread returns number of read blocks. This caused Unrecognized archive format errors, because the decompressed archive was truncated.

Also libarchive takes care of closing the input stream using the close callback, so we must not do it ourselves..

Related: rhbz#508242
---
 loader/rpmextract.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/loader/rpmextract.c b/loader/rpmextract.c
index 0d99a38..fafe46e 100644
--- a/loader/rpmextract.c
+++ b/loader/rpmextract.c
@@ -57,7 +57,7 @@ ssize_t rpm_myread(struct archive *a, void *client_data, const void **buff)
 {
     struct cpio_mydata *mydata = client_data;
     *buff = mydata->buffer;
-    return Fread(mydata->buffer, BUFFERSIZE, 1, mydata->gzdi);
+    return Fread(mydata->buffer, 1, BUFFERSIZE, mydata->gzdi);
 }
 
 int rpm_myclose(struct archive *a, void *client_data)
@@ -230,7 +230,7 @@ int explodeRPM(const char *source,
     free(rpmio_flags);
 
     if (gzdi == NULL) {
-        logMessage(ERROR, "cannot re-open payload: %s\n", Fstrerror(gzdi));
+        logMessage(ERROR, "cannot re-open payload: %s", Fstrerror(gzdi));
         return EXIT_FAILURE;
     }
 
@@ -345,8 +345,7 @@ int explodeRPM(const char *source,
             archive_read_data_skip(cpio);
     }
 
-    archive_read_finish(cpio);
-    Fclose(gzdi);
+    rc = archive_read_finish(cpio); /* Also closes the RPM stream using callback */
 
     return rc != ARCHIVE_OK;
 }
-- 
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux