summaryrefslogtreecommitdiff
path: root/rpm2cpio.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-03-14 10:09:35 +0200
committerPanu Matilainen <pmatilai@redhat.com>2012-03-14 11:20:42 +0200
commit1e318f557c0f8b8296f0263afa3a444b9b9d7f22 (patch)
tree1c51300e6801e8dc05c348fc42e303d4d212e83d /rpm2cpio.c
parentaa90bda89b15389f59fdf4c836892561f24a6479 (diff)
downloadrpm-1e318f557c0f8b8296f0263afa3a444b9b9d7f22.tar.gz
rpm-1e318f557c0f8b8296f0263afa3a444b9b9d7f22.tar.bz2
rpm-1e318f557c0f8b8296f0263afa3a444b9b9d7f22.zip
Make rpm2cpio exit code accurate for large packages and partial copy
- Grab the uncompressed payload size from header and compare number of bytes copied to that for exit code. Previously, truncated payloads could have returned with success. This also fixes the exit code for large payloads (RhBug:790396)
Diffstat (limited to 'rpm2cpio.c')
-rw-r--r--rpm2cpio.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/rpm2cpio.c b/rpm2cpio.c
index ed3051ed3..89ebdfac0 100644
--- a/rpm2cpio.c
+++ b/rpm2cpio.c
@@ -18,6 +18,7 @@ int main(int argc, char *argv[])
Header h;
char * rpmio_flags = NULL;
int rc;
+ off_t payload_size;
FD_t gzdi;
setprogname(argv[0]); /* Retrofit glibc __progname */
@@ -69,9 +70,10 @@ int main(int argc, char *argv[])
break;
}
- /* Retrieve type of payload compression. */
+ /* Retrieve payload size and compression type. */
{ const char *compr = headerGetString(h, RPMTAG_PAYLOADCOMPRESSOR);
rpmio_flags = rstrscat(NULL, "r.", compr ? compr : "gzip", NULL);
+ payload_size = headerGetNumber(h, RPMTAG_LONGARCHIVESIZE);
}
gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
@@ -82,8 +84,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- rc = ufdCopy(gzdi, fdo);
- rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
+ rc = (ufdCopy(gzdi, fdo) == payload_size) ? EXIT_SUCCESS : EXIT_FAILURE;
+
Fclose(fdo);
Fclose(gzdi); /* XXX gzdi == fdi */