From 5e14d06a9bf38f8b4707415e2ab03f4794d56e39 Mon Sep 17 00:00:00 2001 From: Ngie Cooper Date: Mon, 12 Dec 2016 19:32:32 -0800 Subject: Don't leak `entry` in `file_to_archive` if archive_read_disk_entry_from_file fails with `ARCHIVE_FAILED` This greatly reduces memory usage when the call fails, e.g. a file cannot be stat'ed Confirmed with the following snippet: % d=/tmp/cpio_test % mkdir -p $d % while : ; do echo /nonexistent ; done | cpio -dump $d 2>/dev/null Reported by: Coverity CID: 1016757 --- cpio/cpio.c | 1 + 1 file changed, 1 insertion(+) (limited to 'cpio/cpio.c') diff --git a/cpio/cpio.c b/cpio/cpio.c index 373e6da7..6c20ee68 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -703,6 +703,7 @@ file_to_archive(struct cpio *cpio, const char *srcpath) lafe_warnc(0, "%s", archive_error_string(cpio->archive_read_disk)); if (r <= ARCHIVE_FAILED) { + archive_entry_free(entry); cpio->return_value = 1; return (r); } -- cgit v1.2.1