rpms/libtar/devel libtar-1.2.11-fix-memleak.patch, 1.1, 1.2 libtar.spec, 1.21, 1.22 libtar-1.2.11-fix-memleak2.patch, 1.1, NONE

Kamil Dudka kdudka at fedoraproject.org
Thu May 27 14:10:57 UTC 2010


Author: kdudka

Update of /cvs/extras/rpms/libtar/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv5552

Modified Files:
	libtar-1.2.11-fix-memleak.patch libtar.spec 
Removed Files:
	libtar-1.2.11-fix-memleak2.patch 
Log Message:
- Completed review of memory leaks related patches (#589056)

libtar-1.2.11-fix-memleak.patch:
 lib/decode.c    |    2 -
 lib/extract.c   |   94 ++++++++++++++++++++++++++++++++++++++++++++------------
 lib/handle.c    |    1 
 lib/wrapper.c   |   12 ++++++-
 libtar/libtar.c |   30 +++++++++++------
 5 files changed, 106 insertions(+), 33 deletions(-)

Index: libtar-1.2.11-fix-memleak.patch
===================================================================
RCS file: /cvs/extras/rpms/libtar/devel/libtar-1.2.11-fix-memleak.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- libtar-1.2.11-fix-memleak.patch	3 May 2010 08:43:53 -0000	1.1
+++ libtar-1.2.11-fix-memleak.patch	27 May 2010 14:10:56 -0000	1.2
@@ -1,7 +1,15 @@
-diff -Naur libtar-1.2.11/lib/decode.c libtar-1.2.11.fixmem/lib/decode.c
---- libtar-1.2.11/lib/decode.c	2003-01-07 07:10:59.000000000 +0530
-+++ libtar-1.2.11.fixmem/lib/decode.c	2010-04-30 16:05:31.000000000 +0530
-@@ -29,7 +29,7 @@
+ lib/decode.c    |    2 +-
+ lib/extract.c   |   94 +++++++++++++++++++++++++++++++++++++++++++------------
+ lib/handle.c    |    1 +
+ lib/wrapper.c   |   12 ++++++-
+ libtar/libtar.c |   30 +++++++++++------
+ 5 files changed, 106 insertions(+), 33 deletions(-)
+
+diff --git a/lib/decode.c b/lib/decode.c
+index 794c868..c2c2baa 100644
+--- a/lib/decode.c
++++ b/lib/decode.c
+@@ -29,7 +29,7 @@ th_get_pathname(TAR *t)
  	char filename[MAXPATHLEN];
  
  	if (t->th_buf.gnu_longname)
@@ -10,10 +18,11 @@ diff -Naur libtar-1.2.11/lib/decode.c li
  
  	if (t->th_buf.prefix[0] != '\0')
  	{
-diff -Naur libtar-1.2.11/lib/extract.c libtar-1.2.11.fixmem/lib/extract.c
---- libtar-1.2.11/lib/extract.c	2010-04-30 16:04:27.000000000 +0530
-+++ libtar-1.2.11.fixmem/lib/extract.c	2010-04-30 16:29:10.000000000 +0530
-@@ -44,9 +44,10 @@
+diff --git a/lib/extract.c b/lib/extract.c
+index cacfe58..8993b95 100644
+--- a/lib/extract.c
++++ b/lib/extract.c
+@@ -44,9 +44,10 @@ tar_set_file_perms(TAR *t, char *realname)
  	uid_t uid;
  	gid_t gid;
  	struct utimbuf ut;
@@ -26,7 +35,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	mode = th_get_mode(t);
  	uid = th_get_uid(t);
  	gid = th_get_gid(t);
-@@ -69,6 +70,7 @@
+@@ -69,6 +70,7 @@ tar_set_file_perms(TAR *t, char *realname)
  				filename, uid, gid, strerror(errno));
  # endif
  #endif /* HAVE_LCHOWN */
@@ -34,7 +43,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  			return -1;
  		}
  
-@@ -78,6 +80,7 @@
+@@ -78,6 +80,7 @@ tar_set_file_perms(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("utime()");
  #endif
@@ -42,7 +51,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  		return -1;
  	}
  
-@@ -87,9 +90,11 @@
+@@ -87,9 +90,11 @@ tar_set_file_perms(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("chmod()");
  #endif
@@ -54,7 +63,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -168,7 +173,7 @@
+@@ -168,7 +173,7 @@ tar_extract_regfile(TAR *t, char *realname)
  	int fdout;
  	int i, k;
  	char buf[T_BLOCKSIZE];
@@ -63,7 +72,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  #ifdef DEBUG
  	printf("==> tar_extract_regfile(t=0x%lx, realname=\"%s\")\n", t,
-@@ -181,14 +186,18 @@
+@@ -181,14 +186,18 @@ tar_extract_regfile(TAR *t, char *realname)
  		return -1;
  	}
  
@@ -83,7 +92,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  #ifdef DEBUG
  	printf("  ==> extracting: %s (mode %04o, uid %d, gid %d, %d bytes)\n",
-@@ -204,6 +213,7 @@
+@@ -204,6 +213,7 @@ tar_extract_regfile(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("open()");
  #endif
@@ -91,7 +100,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  		return -1;
  	}
  
-@@ -235,23 +245,30 @@
+@@ -235,23 +245,30 @@ tar_extract_regfile(TAR *t, char *realname)
  		{
  			if (k != -1)
  				errno = EINVAL;
@@ -123,7 +132,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -290,7 +307,7 @@
+@@ -290,7 +307,7 @@ tar_skip_regfile(TAR *t)
  int
  tar_extract_hardlink(TAR * t, char *realname)
  {
@@ -132,7 +141,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	char *linktgt = NULL;
  	linkname_t *lnp;
  	libtar_hashptr_t hp;
-@@ -301,9 +318,13 @@
+@@ -301,9 +318,13 @@ tar_extract_hardlink(TAR * t, char *realname)
  		return -1;
  	}
  
@@ -147,7 +156,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	libtar_hashptr_reset(&hp);
  	if (libtar_hash_getkey(t->h, &hp, th_get_linkname(t),
  			       (libtar_matchfunc_t)libtar_str_match) != 0)
-@@ -322,9 +343,11 @@
+@@ -322,9 +343,11 @@ tar_extract_hardlink(TAR * t, char *realname)
  #ifdef DEBUG
  		perror("link()");
  #endif
@@ -159,7 +168,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -333,7 +356,7 @@
+@@ -333,7 +356,7 @@ tar_extract_hardlink(TAR * t, char *realname)
  int
  tar_extract_symlink(TAR *t, char *realname)
  {
@@ -168,7 +177,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  	if (!TH_ISSYM(t))
  	{
-@@ -341,9 +364,13 @@
+@@ -341,9 +364,13 @@ tar_extract_symlink(TAR *t, char *realname)
  		return -1;
  	}
  
@@ -183,7 +192,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  	if (unlink(filename) == -1 && errno != ENOENT)
  		return -1;
-@@ -357,9 +384,11 @@
+@@ -357,9 +384,11 @@ tar_extract_symlink(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("symlink()");
  #endif
@@ -195,7 +204,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -370,7 +399,7 @@
+@@ -370,7 +399,7 @@ tar_extract_chardev(TAR *t, char *realname)
  {
  	mode_t mode;
  	unsigned long devmaj, devmin;
@@ -204,7 +213,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  	if (!TH_ISCHR(t))
  	{
-@@ -378,14 +407,18 @@
+@@ -378,14 +407,18 @@ tar_extract_chardev(TAR *t, char *realname)
  		return -1;
  	}
  
@@ -225,7 +234,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  #ifdef DEBUG
  	printf("  ==> extracting: %s (character device %ld,%ld)\n",
  	       filename, devmaj, devmin);
-@@ -396,9 +429,11 @@
+@@ -396,9 +429,11 @@ tar_extract_chardev(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("mknod()");
  #endif
@@ -237,7 +246,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -409,7 +444,7 @@
+@@ -409,7 +444,7 @@ tar_extract_blockdev(TAR *t, char *realname)
  {
  	mode_t mode;
  	unsigned long devmaj, devmin;
@@ -246,7 +255,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  	if (!TH_ISBLK(t))
  	{
-@@ -417,13 +452,17 @@
+@@ -417,13 +452,17 @@ tar_extract_blockdev(TAR *t, char *realname)
  		return -1;
  	}
  
@@ -265,7 +274,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  #ifdef DEBUG
  	printf("  ==> extracting: %s (block device %ld,%ld)\n",
-@@ -435,9 +474,11 @@
+@@ -435,9 +474,11 @@ tar_extract_blockdev(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("mknod()");
  #endif
@@ -277,7 +286,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -447,19 +488,22 @@
+@@ -447,19 +488,22 @@ int
  tar_extract_dir(TAR *t, char *realname)
  {
  	mode_t mode;
@@ -303,7 +312,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  #ifdef DEBUG
  	printf("  ==> extracting: %s (mode %04o, directory)\n", filename,
-@@ -474,6 +518,7 @@
+@@ -474,6 +518,7 @@ tar_extract_dir(TAR *t, char *realname)
  #ifdef DEBUG
  				perror("chmod()");
  #endif
@@ -311,7 +320,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  				return -1;
  			}
  			else
-@@ -481,6 +526,7 @@
+@@ -481,6 +526,7 @@ tar_extract_dir(TAR *t, char *realname)
  #ifdef DEBUG
  				puts("  *** using existing directory");
  #endif
@@ -319,7 +328,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  				return 1;
  			}
  		}
-@@ -489,10 +535,12 @@
+@@ -489,10 +535,12 @@ tar_extract_dir(TAR *t, char *realname)
  #ifdef DEBUG
  			perror("mkdir()");
  #endif
@@ -333,7 +342,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-@@ -502,7 +550,7 @@
+@@ -502,7 +550,7 @@ int
  tar_extract_fifo(TAR *t, char *realname)
  {
  	mode_t mode;
@@ -342,7 +351,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  	if (!TH_ISFIFO(t))
  	{
-@@ -510,11 +558,15 @@
+@@ -510,11 +558,15 @@ tar_extract_fifo(TAR *t, char *realname)
  		return -1;
  	}
  
@@ -359,7 +368,7 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  
  #ifdef DEBUG
  	printf("  ==> extracting: %s (fifo)\n", filename);
-@@ -524,9 +576,11 @@
+@@ -524,9 +576,11 @@ tar_extract_fifo(TAR *t, char *realname)
  #ifdef DEBUG
  		perror("mkfifo()");
  #endif
@@ -371,18 +380,23 @@ diff -Naur libtar-1.2.11/lib/extract.c l
  	return 0;
  }
  
-diff -Naur libtar-1.2.11/lib/wrapper.c libtar-1.2.11.fixmem/lib/wrapper.c
---- libtar-1.2.11/lib/wrapper.c	2010-04-30 16:04:27.000000000 +0530
-+++ libtar-1.2.11.fixmem/lib/wrapper.c	2010-05-03 13:52:57.000000000 +0530
-@@ -13,7 +13,6 @@
- #include <internal.h>
- 
- #include <stdio.h>
--#include <stdlib.h>
- #include <sys/param.h>
- #include <dirent.h>
- #include <errno.h>
-@@ -36,7 +35,10 @@
+diff --git a/lib/handle.c b/lib/handle.c
+index ae974b9..e3a48cb 100644
+--- a/lib/handle.c
++++ b/lib/handle.c
+@@ -82,6 +82,7 @@ tar_open(TAR **t, char *pathname, tartype_t *type,
+ 	(*t)->fd = (*((*t)->type->openfunc))(pathname, oflags, mode);
+ 	if ((*t)->fd == -1)
+ 	{
++		libtar_hash_free((*t)->h, NULL);
+ 		free(*t);
+ 		return -1;
+ 	}
+diff --git a/lib/wrapper.c b/lib/wrapper.c
+index 51d5086..e60a530 100644
+--- a/lib/wrapper.c
++++ b/lib/wrapper.c
+@@ -36,7 +36,10 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
  		if (fnmatch(globname, filename, FNM_PATHNAME | FNM_PERIOD))
  		{
  			if (TH_ISREG(t) && tar_skip_regfile(t))
@@ -393,7 +407,7 @@ diff -Naur libtar-1.2.11/lib/wrapper.c l
  			continue;
  		}
  		if (t->options & TAR_VERBOSE)
-@@ -46,7 +48,11 @@
+@@ -46,7 +49,11 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
  		else
  			strlcpy(buf, filename, sizeof(buf));
  		if (tar_extract_file(t, filename) != 0)
@@ -405,7 +419,7 @@ diff -Naur libtar-1.2.11/lib/wrapper.c l
  	}
  
  	return (i == 1 ? 0 : -1);
-@@ -77,13 +83,16 @@
+@@ -77,13 +84,16 @@ tar_extract_all(TAR *t, char *prefix)
  			snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
  		else
  			strlcpy(buf, filename, sizeof(buf));
@@ -423,44 +437,110 @@ diff -Naur libtar-1.2.11/lib/wrapper.c l
  	}
  
  	return (i == 1 ? 0 : -1);
-diff -Naur libtar-1.2.11/libtar/libtar.c libtar-1.2.11.fixmem/libtar/libtar.c
---- libtar-1.2.11/libtar/libtar.c	2010-04-30 16:04:27.000000000 +0530
-+++ libtar-1.2.11.fixmem/libtar/libtar.c	2010-05-03 13:50:05.000000000 +0530
-@@ -19,7 +19,6 @@
- #include <sys/param.h>
- 
- #ifdef STDC_HEADERS
--# include <stdlib.h>
- # include <string.h>
+diff --git a/libtar/libtar.c b/libtar/libtar.c
+index a6cef72..f06c5b8 100644
+--- a/libtar/libtar.c
++++ b/libtar/libtar.c
+@@ -249,7 +249,9 @@ extract(char *tarfile, char *rootdir)
  #endif
- 
-@@ -92,10 +91,6 @@
+ 	if (tar_extract_all(t, rootdir) != 0)
+ 	{
++		
+ 		fprintf(stderr, "tar_extract_all(): %s\n", strerror(errno));
++		tar_close(t);
  		return -1;
  	}
  
--	/* This is a bad thing to do on big-endian lp64 systems, where the
--	   size and placement of integers is different than pointers.
--	   However, to fix the problem 4 wrapper functions would be needed and
--	   an extra bit of data associating GZF with the wrapper functions.  */
- 	return (int)gzf;
+@@ -267,12 +269,13 @@ extract(char *tarfile, char *rootdir)
+ 
+ 
+ void
+-usage()
++usage(void *rootdir)
+ {
+ 	printf("Usage: %s [-C rootdir] [-g] [-z] -x|-t filename.tar\n",
+ 	       progname);
+ 	printf("       %s [-C rootdir] [-g] [-z] -c filename.tar ...\n",
+ 	       progname);
++	free(rootdir);
+ 	exit(-1);
  }
  
-@@ -289,6 +284,7 @@
+@@ -289,6 +292,7 @@ main(int argc, char *argv[])
  	int c;
  	int mode = 0;
  	libtar_list_t *l;
-+	int return_code = 0;
++	int return_code = -2;
  
  	progname = basename(argv[0]);
  
-@@ -354,7 +350,9 @@
+@@ -310,17 +314,17 @@ main(int argc, char *argv[])
+ 			break;
+ 		case 'c':
+ 			if (mode)
+-				usage();
++				usage(rootdir);
+ 			mode = MODE_CREATE;
+ 			break;
+ 		case 'x':
+ 			if (mode)
+-				usage();
++				usage(rootdir);
+ 			mode = MODE_EXTRACT;
+ 			break;
+ 		case 't':
+ 			if (mode)
+-				usage();
++				usage(rootdir);
+ 			mode = MODE_LIST;
+ 			break;
+ #ifdef HAVE_LIBZ
+@@ -329,7 +333,7 @@ main(int argc, char *argv[])
+ 			break;
+ #endif /* HAVE_LIBZ */
+ 		default:
+-			usage();
++			usage(rootdir);
+ 		}
+ 
+ 	if (!mode || ((argc - optind) < (mode == MODE_CREATE ? 2 : 1)))
+@@ -338,7 +342,7 @@ main(int argc, char *argv[])
+ 		printf("argc - optind == %d\tmode == %d\n", argc - optind,
+ 		       mode);
+ #endif
+-		usage();
++		usage(rootdir);
+ 	}
+ 
+ #ifdef DEBUG
+@@ -348,21 +352,25 @@ main(int argc, char *argv[])
+ 	switch (mode)
+ 	{
+ 	case MODE_EXTRACT:
+-		return extract(argv[optind], rootdir);
++		return_code = extract(argv[optind], rootdir);
++		break;
+ 	case MODE_CREATE:
+ 		tarfile = argv[optind];
  		l = libtar_list_new(LIST_QUEUE, NULL);
  		for (c = optind + 1; c < argc; c++)
  			libtar_list_add(l, argv[c]);
 -		return create(tarfile, rootdir, l);
 +		return_code =  create(tarfile, rootdir, l);
 +		libtar_list_free (l, NULL);
-+		return return_code;
++		break;
  	case MODE_LIST:
- 		return list(argv[optind]);
+-		return list(argv[optind]);
++		return_code = list(argv[optind]);
++		break;
  	default:
+ 		break;
+ 	}
+ 
+-	/* NOTREACHED */
+-	return -2;
++	free(rootdir);
++	return return_code;
+ }
+ 
+ 


Index: libtar.spec
===================================================================
RCS file: /cvs/extras/rpms/libtar/devel/libtar.spec,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -p -r1.21 -r1.22
--- libtar.spec	3 May 2010 10:10:13 -0000	1.21
+++ libtar.spec	27 May 2010 14:10:56 -0000	1.22
@@ -1,7 +1,7 @@
 Summary:        Tar file manipulation API
 Name:           libtar
 Version:        1.2.11
-Release:        18%{?dist}
+Release:        19%{?dist}
 License:        MIT
 Group:          System Environment/Libraries
 URL:            http://www.feep.net/libtar/
@@ -12,7 +12,6 @@ Patch2:         libtar-macro.patch
 Patch3:		libtar-1.2.11-tar_header.patch
 Patch4:		libtar-1.2.11-mem-deref.patch
 Patch5:		libtar-1.2.11-fix-memleak.patch
-Patch6:		libtar-1.2.11-fix-memleak2.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 BuildRequires:  zlib-devel libtool
 
@@ -40,7 +39,6 @@ developing applications that use %{name}
 %patch3 -p1 -b .tar_header
 %patch4 -p1 -b .deref
 %patch5 -p1 -b .fixmem
-%patch6 -p1 -b .fixmem2
 
 # set correct version for .so build
 %define ltversion %(echo %{version} | tr '.' ':')
@@ -94,6 +92,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Thu May 27 2010 Kamil Dudka <kdudka at redhat.com> - 1.2.11.19
+- Completed review of memory leaks related patches (#589056)
+
 * Mon May 3 2010 Huzaifa Sidhpurwala <huzaifas at redhat.com> - 1.2.11.18
 - Fix more memory leaks
 


--- libtar-1.2.11-fix-memleak2.patch DELETED ---



More information about the scm-commits mailing list