diff --git a/SOURCES/libtar-1.2.11-bz785760.patch b/SOURCES/libtar-1.2.11-bz785760.patch new file mode 100644 index 0000000..5136b30 --- /dev/null +++ b/SOURCES/libtar-1.2.11-bz785760.patch @@ -0,0 +1,94 @@ +From 6595e6491a472bc4e7f81ed7fe2879c67b3873fe Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Tue, 7 Feb 2012 13:50:55 +0100 +Subject: [PATCH] libtar - rhbz #785760 + +--- + lib/append.c | 14 ++++++++------ + lib/extract.c | 2 ++ + libtar/libtar.c | 3 +++ + 3 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/lib/append.c b/lib/append.c +index 5489168..690202b 100644 +--- a/lib/append.c ++++ b/lib/append.c +@@ -216,6 +216,7 @@ tar_append_regfile(TAR *t, char *realname) + int filefd; + int i, j; + size_t size; ++ int rv = -1; + + filefd = open(realname, O_RDONLY); + if (filefd == -1) +@@ -234,25 +235,26 @@ tar_append_regfile(TAR *t, char *realname) + { + if (j != -1) + errno = EINVAL; +- return -1; ++ goto fail; + } + if (tar_block_write(t, &block) == -1) +- return -1; ++ goto fail; + } + + if (i > 0) + { + j = read(filefd, &block, i); + if (j == -1) +- return -1; ++ goto fail; + memset(&(block[i]), 0, T_BLOCKSIZE - i); + if (tar_block_write(t, &block) == -1) +- return -1; ++ goto fail; + } + ++ rv = 0; ++fail: + close(filefd); +- +- return 0; ++ return rv; + } + + +diff --git a/lib/extract.c b/lib/extract.c +index b783d87..b36d447 100644 +--- a/lib/extract.c ++++ b/lib/extract.c +@@ -245,6 +245,7 @@ tar_extract_regfile(TAR *t, char *realname) + { + if (k != -1) + errno = EINVAL; ++ close(fdout); + free (pn); + return -1; + } +@@ -253,6 +254,7 @@ tar_extract_regfile(TAR *t, char *realname) + if (write(fdout, buf, + ((i > T_BLOCKSIZE) ? T_BLOCKSIZE : i)) == -1) + { ++ close(fdout); + free (pn); + return -1; + } +diff --git a/libtar/libtar.c b/libtar/libtar.c +index 83564c8..673c90e 100644 +--- a/libtar/libtar.c ++++ b/libtar/libtar.c +@@ -83,7 +83,10 @@ gzopen_frontend(char *pathname, int oflags, int mode) + return -1; + + if ((oflags & O_CREAT) && fchmod(fd, mode)) ++ { ++ close(fd); + return -1; ++ } + + gzf = gzdopen(fd, gzoflags); + if (!gzf) +-- +1.7.1 + diff --git a/SPECS/libtar.spec b/SPECS/libtar.spec index 5b80453..994606a 100644 --- a/SPECS/libtar.spec +++ b/SPECS/libtar.spec @@ -1,7 +1,7 @@ Summary: Tar file manipulation API Name: libtar Version: 1.2.11 -Release: 28%{?dist} +Release: 29%{?dist} License: MIT Group: System Environment/Libraries URL: http://www.feep.net/libtar/ @@ -14,6 +14,7 @@ Patch4: libtar-1.2.11-mem-deref.patch Patch5: libtar-1.2.11-fix-memleak.patch Patch6: libtar-1.2.11-bz729009.patch Patch7: libtar-1.2.11-CVE-2013-4397.patch +Patch8: libtar-1.2.11-bz785760.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildRequires: zlib-devel libtool @@ -43,6 +44,7 @@ developing applications that use %{name}. %patch5 -p1 -b .fixmem %patch6 -p1 %patch7 -p1 +%patch8 -p1 # set correct version for .so build %global ltversion %(echo %{version} | tr '.' ':') @@ -89,6 +91,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %changelog +* Tue Apr 21 2015 Kamil Dudka - 1.2.11-29 +- fix resource leaks found by cppcheck (#785760) + * Fri Jan 24 2014 Daniel Mach - 1.2.11-28 - Mass rebuild 2014-01-24