Make rpm2cpio exit code accurate for large packages
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.
This commit is contained in:
parent
499405d5b4
commit
91210177c1
@ -10,6 +10,7 @@ int main(int argc, char **argv)
|
||||
FD_t fdi, fdo;
|
||||
Header h;
|
||||
char * rpmio_flags;
|
||||
const int * archive_size;
|
||||
int rc, isSource;
|
||||
FD_t gzdi;
|
||||
|
||||
@ -57,6 +58,10 @@ int main(int argc, char **argv)
|
||||
t = stpcpy(t, ".lzdio");
|
||||
if (!strcmp(payload_compressor, "xz"))
|
||||
t = stpcpy(t, ".xzdio");
|
||||
|
||||
if (!headerGetEntry(h, RPMTAG_ARCHIVESIZE, NULL,
|
||||
(void **) &archive_size, NULL))
|
||||
archive_size = NULL;
|
||||
}
|
||||
|
||||
gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
|
||||
@ -66,7 +71,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
rc = ufdCopy(gzdi, fdo);
|
||||
rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
rc = archive_size
|
||||
? (*archive_size != rc ? EXIT_FAILURE : EXIT_SUCCESS)
|
||||
: ((rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
if (Fclose(fdo) < 0)
|
||||
rc = EXIT_FAILURE;
|
||||
|
||||
|
@ -1285,8 +1285,8 @@ void urlSetCallback(rpmCallbackFunction notify, void *notifyData, int notifyCoun
|
||||
int ufdCopy(FD_t sfd, FD_t tfd)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int itemsRead;
|
||||
int itemsCopied = 0;
|
||||
unsigned int itemsRead;
|
||||
unsigned int itemsCopied = 0;
|
||||
int rc = 0;
|
||||
int notifier = -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user