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;
|
FD_t fdi, fdo;
|
||||||
Header h;
|
Header h;
|
||||||
char * rpmio_flags;
|
char * rpmio_flags;
|
||||||
|
const int * archive_size;
|
||||||
int rc, isSource;
|
int rc, isSource;
|
||||||
FD_t gzdi;
|
FD_t gzdi;
|
||||||
|
|
||||||
@ -57,6 +58,10 @@ int main(int argc, char **argv)
|
|||||||
t = stpcpy(t, ".lzdio");
|
t = stpcpy(t, ".lzdio");
|
||||||
if (!strcmp(payload_compressor, "xz"))
|
if (!strcmp(payload_compressor, "xz"))
|
||||||
t = stpcpy(t, ".xzdio");
|
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 */
|
gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
|
||||||
@ -66,7 +71,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ufdCopy(gzdi, fdo);
|
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)
|
if (Fclose(fdo) < 0)
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
|
|
||||||
|
@ -1285,8 +1285,8 @@ void urlSetCallback(rpmCallbackFunction notify, void *notifyData, int notifyCoun
|
|||||||
int ufdCopy(FD_t sfd, FD_t tfd)
|
int ufdCopy(FD_t sfd, FD_t tfd)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int itemsRead;
|
unsigned int itemsRead;
|
||||||
int itemsCopied = 0;
|
unsigned int itemsCopied = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int notifier = -1;
|
int notifier = -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user