diff options
author | Ngie Cooper <yanegomi@gmail.com> | 2016-12-12 19:32:32 -0800 |
---|---|---|
committer | Ngie Cooper <yanegomi@gmail.com> | 2016-12-12 19:39:11 -0800 |
commit | 5e14d06a9bf38f8b4707415e2ab03f4794d56e39 (patch) | |
tree | 03ee44396447366d4bec91d83076cadb578e7590 | |
parent | 54546be8a7a2e69738247d68f4f6c253430a3d6f (diff) | |
download | libarchive-5e14d06a9bf38f8b4707415e2ab03f4794d56e39.tar.gz |
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
-rw-r--r-- | cpio/cpio.c | 1 |
1 files changed, 1 insertions, 0 deletions
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); } |