Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian Kernel (http://www.linux-archive.org/debian-kernel/)
-   -   Fix the order of arguments in archive read callback and archive closing. (http://www.linux-archive.org/debian-kernel/372642-fix-order-arguments-archive-read-callback-archive-closing.html)

Martin Sivak 05-18-2010 12:15 PM

Fix the order of arguments in archive read callback and archive closing.
 
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
", 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Ales Kozumplik 05-18-2010 12:36 PM

Fix the order of arguments in archive read callback and archive closing.
 
On 05/18/2010 02:15 PM, Martin Sivak wrote:

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
---


Also Ack.

Ales

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


All times are GMT. The time now is 09:46 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.