From: Ngie Cooper Date: Tue, 13 Dec 2016 03:32:32 +0000 (-0800) Subject: Don't leak `entry` in `file_to_archive` if archive_read_disk_entry_from_file X-Git-Tag: v3.3.0~73^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e14d06a9bf38f8b4707415e2ab03f4794d56e39;p=thirdparty%2Flibarchive.git 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 --- diff --git a/cpio/cpio.c b/cpio/cpio.c index 373e6da78..6c20ee683 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); }