update to 1.2.20 [release 1.2.20-1mamba;Tue Oct 15 2013]

This commit is contained in:
Automatic Build System 2024-01-06 05:53:35 +01:00
parent 916dff679c
commit 01726c736f
6 changed files with 27665 additions and 0 deletions

View File

@ -1,2 +1,5 @@
# libtar
libtar is a C library for manipulating POSIX tar files.
It handles adding and extracting files to/from a tar archive.

View File

@ -0,0 +1,546 @@
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)
- return t->th_buf.gnu_longname;
+ return strdup(t->th_buf.gnu_longname);
if (t->th_buf.prefix[0] != '\0')
{
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;
- char *filename;
+ char *filename,*pn;
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
uid = th_get_uid(t);
gid = th_get_gid(t);
@@ -69,6 +70,7 @@ tar_set_file_perms(TAR *t, char *realname)
filename, uid, gid, strerror(errno));
# endif
#endif /* HAVE_LCHOWN */
+ free (pn);
return -1;
}
@@ -78,6 +80,7 @@ tar_set_file_perms(TAR *t, char *realname)
#ifdef DEBUG
perror("utime()");
#endif
+ free (pn);
return -1;
}
@@ -87,9 +90,11 @@ tar_set_file_perms(TAR *t, char *realname)
#ifdef DEBUG
perror("chmod()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
@@ -168,7 +173,7 @@ tar_extract_regfile(TAR *t, char *realname)
int fdout;
int i, k;
char buf[T_BLOCKSIZE];
- char *filename;
+ char *filename,*pn;
#ifdef DEBUG
printf("==> tar_extract_regfile(t=0x%lx, realname=\"%s\")\n", t,
@@ -181,14 +186,18 @@ tar_extract_regfile(TAR *t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
size = th_get_size(t);
uid = th_get_uid(t);
gid = th_get_gid(t);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
#ifdef DEBUG
printf(" ==> extracting: %s (mode %04o, uid %d, gid %d, %d bytes)\n",
@@ -204,6 +213,7 @@ tar_extract_regfile(TAR *t, char *realname)
#ifdef DEBUG
perror("open()");
#endif
+ free (pn);
return -1;
}
@@ -235,23 +245,30 @@ tar_extract_regfile(TAR *t, char *realname)
{
if (k != -1)
errno = EINVAL;
+ free (pn);
return -1;
}
/* write block to output file */
if (write(fdout, buf,
((i > T_BLOCKSIZE) ? T_BLOCKSIZE : i)) == -1)
+ {
+ free (pn);
return -1;
+ }
}
/* close output file */
if (close(fdout) == -1)
+ {
+ free (pn);
return -1;
+ }
#ifdef DEBUG
printf("### done extracting %s\n", filename);
#endif
-
+ free (pn);
return 0;
}
@@ -290,7 +307,7 @@ tar_skip_regfile(TAR *t)
int
tar_extract_hardlink(TAR * t, char *realname)
{
- char *filename;
+ char *filename,*pn;
char *linktgt = NULL;
linkname_t *lnp;
libtar_hashptr_t hp;
@@ -301,9 +318,13 @@ tar_extract_hardlink(TAR * t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
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 @@ tar_extract_hardlink(TAR * t, char *realname)
#ifdef DEBUG
perror("link()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
@@ -333,7 +356,7 @@ tar_extract_hardlink(TAR * t, char *realname)
int
tar_extract_symlink(TAR *t, char *realname)
{
- char *filename;
+ char *filename,*pn;
if (!TH_ISSYM(t))
{
@@ -341,9 +364,13 @@ tar_extract_symlink(TAR *t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
if (unlink(filename) == -1 && errno != ENOENT)
return -1;
@@ -357,9 +384,11 @@ tar_extract_symlink(TAR *t, char *realname)
#ifdef DEBUG
perror("symlink()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
@@ -370,7 +399,7 @@ tar_extract_chardev(TAR *t, char *realname)
{
mode_t mode;
unsigned long devmaj, devmin;
- char *filename;
+ char *filename,*pn;
if (!TH_ISCHR(t))
{
@@ -378,14 +407,18 @@ tar_extract_chardev(TAR *t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
devmaj = th_get_devmajor(t);
devmin = th_get_devminor(t);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
-
+ }
+
#ifdef DEBUG
printf(" ==> extracting: %s (character device %ld,%ld)\n",
filename, devmaj, devmin);
@@ -396,9 +429,11 @@ tar_extract_chardev(TAR *t, char *realname)
#ifdef DEBUG
perror("mknod()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
@@ -409,7 +444,7 @@ tar_extract_blockdev(TAR *t, char *realname)
{
mode_t mode;
unsigned long devmaj, devmin;
- char *filename;
+ char *filename,*pn;
if (!TH_ISBLK(t))
{
@@ -417,13 +452,17 @@ tar_extract_blockdev(TAR *t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
devmaj = th_get_devmajor(t);
devmin = th_get_devminor(t);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
#ifdef DEBUG
printf(" ==> extracting: %s (block device %ld,%ld)\n",
@@ -435,9 +474,11 @@ tar_extract_blockdev(TAR *t, char *realname)
#ifdef DEBUG
perror("mknod()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
@@ -447,19 +488,22 @@ int
tar_extract_dir(TAR *t, char *realname)
{
mode_t mode;
- char *filename;
+ char *filename,*pn;
if (!TH_ISDIR(t))
{
errno = EINVAL;
return -1;
}
-
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
#ifdef DEBUG
printf(" ==> extracting: %s (mode %04o, directory)\n", filename,
@@ -474,6 +518,7 @@ tar_extract_dir(TAR *t, char *realname)
#ifdef DEBUG
perror("chmod()");
#endif
+ free (pn);
return -1;
}
else
@@ -481,6 +526,7 @@ tar_extract_dir(TAR *t, char *realname)
#ifdef DEBUG
puts(" *** using existing directory");
#endif
+ free (pn);
return 1;
}
}
@@ -489,10 +535,12 @@ tar_extract_dir(TAR *t, char *realname)
#ifdef DEBUG
perror("mkdir()");
#endif
+ free (pn);
return -1;
}
}
-
+
+ free (pn);
return 0;
}
@@ -502,7 +550,7 @@ int
tar_extract_fifo(TAR *t, char *realname)
{
mode_t mode;
- char *filename;
+ char *filename,*pn;
if (!TH_ISFIFO(t))
{
@@ -510,11 +558,15 @@ tar_extract_fifo(TAR *t, char *realname)
return -1;
}
- filename = (realname ? realname : th_get_pathname(t));
+ pn = th_get_pathname(t);
+ filename = (realname ? realname : pn);
mode = th_get_mode(t);
if (mkdirhier(dirname(filename)) == -1)
+ {
+ free (pn);
return -1;
+ }
#ifdef DEBUG
printf(" ==> extracting: %s (fifo)\n", filename);
@@ -524,9 +576,11 @@ tar_extract_fifo(TAR *t, char *realname)
#ifdef DEBUG
perror("mkfifo()");
#endif
+ free (pn);
return -1;
}
+ free (pn);
return 0;
}
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))
+ {
+ free (filename);
return -1;
+ }
continue;
}
if (t->options & TAR_VERBOSE)
@@ -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)
+ {
+ free (filename);
return -1;
+ }
+ free (filename);
}
return (i == 1 ? 0 : -1);
@@ -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));
- free(filename);
#ifdef DEBUG
printf(" tar_extract_all(): calling tar_extract_file(t, "
"\"%s\")\n", buf);
#endif
if (tar_extract_file(t, buf) != 0)
+ {
+ free (filename);
return -1;
+ }
+ free (filename);
}
return (i == 1 ? 0 : -1);
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
if (tar_extract_all(t, rootdir) != 0)
{
+
fprintf(stderr, "tar_extract_all(): %s\n", strerror(errno));
+ tar_close(t);
return -1;
}
@@ -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 +292,7 @@ main(int argc, char *argv[])
int c;
int mode = 0;
libtar_list_t *l;
+ int return_code = -2;
progname = basename(argv[0]);
@@ -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);
+ break;
case MODE_LIST:
- return list(argv[optind]);
+ return_code = list(argv[optind]);
+ break;
default:
break;
}
- /* NOTREACHED */
- return -2;
+ free(rootdir);
+ return return_code;
}

View File

@ -0,0 +1,24 @@
--- libtar-1.2.11/lib/libtar.h.deref 2009-12-30 16:37:03.790121122 +0100
+++ libtar-1.2.11/lib/libtar.h 2009-12-30 16:37:35.521246633 +0100
@@ -172,6 +172,7 @@ int th_write(TAR *t);
#define TH_ISDIR(t) ((t)->th_buf.typeflag == DIRTYPE \
|| S_ISDIR((mode_t)oct_to_int((t)->th_buf.mode)) \
|| ((t)->th_buf.typeflag == AREGTYPE \
+ && strlen((t)->th_buf.name) \
&& ((t)->th_buf.name[strlen((t)->th_buf.name) - 1] == '/')))
#define TH_ISFIFO(t) ((t)->th_buf.typeflag == FIFOTYPE \
|| S_ISFIFO((mode_t)oct_to_int((t)->th_buf.mode)))
--- libtar-1.2.11/lib/util.c.deref 2003-01-07 02:41:00.000000000 +0100
+++ libtar-1.2.11/lib/util.c 2009-12-30 17:35:51.860121660 +0100
@@ -133,9 +133,7 @@ oct_to_int(char *oct)
{
int i;
- sscanf(oct, "%o", &i);
-
- return i;
+ return sscanf(oct, "%o", &i) == 1 ? i : 0;
}

View File

@ -0,0 +1,80 @@
diff -up libtar-1.2.11/lib/append.c.foo libtar-1.2.11/lib/append.c
--- libtar-1.2.11/lib/append.c.foo 2003-01-07 02:40:59.000000000 +0100
+++ libtar-1.2.11/lib/append.c 2008-04-03 15:08:07.000000000 +0200
@@ -13,6 +13,8 @@
#include <internal.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/param.h>
diff -up libtar-1.2.11/configure.foo libtar-1.2.11/configure
--- libtar-1.2.11/configure.foo 2008-04-03 15:08:07.000000000 +0200
+++ libtar-1.2.11/configure 2008-04-03 15:09:20.000000000 +0200
@@ -4943,8 +4943,8 @@ main ()
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
+ return 2;
+ return 0;
}
_ACEOF
rm -f conftest$ac_exeext
@@ -20083,8 +20083,8 @@ main ()
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
+ return (2);
+ return (0);
}
_ACEOF
rm -f conftest$ac_exeext
@@ -22411,6 +22411,7 @@ cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdio.h>
+#include <string.h>
typedef struct {
int length;
@@ -22437,10 +22438,10 @@ int main() {
if ((snprintf(test1, tests[i].length, "%s", tests[i].test)
!= tests[i].retval) ||
(tests[i].result && strcmp(tests[i].result, test1)))
- exit(1);
+ return (1);
}
- exit(0);
+ return (0);
}
_ACEOF
diff -up libtar-1.2.11/lib/output.c~ libtar-1.2.11/lib/output.c
--- libtar-1.2.11/lib/output.c~ 2008-04-03 15:11:07.000000000 +0200
+++ libtar-1.2.11/lib/output.c 2008-04-03 15:11:07.000000000 +0200
@@ -13,6 +13,7 @@
#include <internal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
diff -up libtar-1.2.11/lib/wrapper.c~ libtar-1.2.11/lib/wrapper.c
--- libtar-1.2.11/lib/wrapper.c~ 2008-04-03 15:11:28.000000000 +0200
+++ libtar-1.2.11/lib/wrapper.c 2008-04-03 15:11:28.000000000 +0200
@@ -13,6 +13,7 @@
#include <internal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/param.h>
#include <dirent.h>
#include <errno.h>

106
libtar.spec Normal file
View File

@ -0,0 +1,106 @@
Name: libtar
Version: 1.2.20
Release: 1mamba
Summary: C library for manipulating POSIX tar files
Group: System/Libraries
Vendor: openmamba
Distribution: openmamba
Packager: Aleph0 <aleph0@openmamba.org>
URL: http://www.feep.net/libtar/
Source: git://repo.or.cz/libtar.git/v%{version}/libtar-%{version}.tar.bz2
#Source: ftp://ftp.feep.net/pub/software/libtar/libtar-%{version}.tar.gz
Patch0: http://ftp.debian.org/debian/pool/main/libt/libtar/libtar_1.2.11-4.diff
Patch1: %{name}-1.2.11-missing-protos.patch
Patch2: %{name}-1.2.11-fix-memleak.patch
Patch3: %{name}-1.2.11-mem-deref.patch
License: BSD
BuildRequires: zlib-devel
BuildRequires: libtool
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
libtar is a C library for manipulating POSIX tar files.
It handles adding and extracting files to/from a tar archive.
%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries
Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release}
%description devel
This package contains the header files, static libraries and development documentation for %{name}.
If you like to develop programs using %{name}, you will need to install %{name}-devel.
%prep
%setup -q
#%patch0 -p1 -z .debian
#%patch1 -p1
#%patch2 -p1
#%patch3 -p1
#% define ltversion %(echo %{version} | tr '.' ':')
#sed -i 's/-rpath $(libdir)/-rpath $(libdir) -version-number %{ltversion}/' lib/Makefile.in
#cd autoconf
#sed '/^m4_include/d;s/ m4_include/ m4][_include/g' aclocal.m4 >psg.m4
#rm acsite.m4 aclocal.m4
#cd .
%build
autoreconf -f -i
#cp /usr/share/libtool/config/config.sub autoconf
#libtoolize --copy
#aclocal -I autoconf
#autoconf
%configure --enable-shared --disable-static
#sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
#sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%make
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%makeinstall
chmod +x %{buildroot}%{_libdir}/libtar.so.0.0.0
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-, root, root)
%{_libdir}/libtar.so.*
%files devel
%defattr(-, root, root)
%{_bindir}/libtar
%{_includedir}/libtar.h
%{_includedir}/libtar_listhash.h
%{_libdir}/libtar.la
%{_libdir}/libtar.so
%{_mandir}/man3/*
%doc ChangeLog README TODO
%changelog
* Tue Oct 15 2013 Automatic Build System <autodist@mambasoft.it> 1.2.20-1mamba
- update to 1.2.20
* Sun Jul 11 2010 Davide Madrisan <davide.madrisan@gmail.com> 1.2.11-5mamba
- build and security fixes
* Tue Jun 12 2007 Aleph0 <aleph0@openmamba.org> 1.2.11-4mamba
- new package mantainer
- move manpages to devel package
- add a patch from Debian which build a shared library
* Wed Jun 29 2005 Davide Madrisan <davide.madrisan@qilinux.it> 1.2.11-3qilnx
- fixed package group
* Tue Jun 28 2005 Alessandro Ramazzina <alessandro.ramazzina@qilinux.it> 1.2.11-2qilnx
- rebuild and moved from devel-contrib repository to devel repository
* Tue Jun 28 2005 Matteo Bernasconi <voyagernm@virgilio.it> 1.2.11-1qilnx
- first build

26906
libtar_1.2.11-4.diff Normal file

File diff suppressed because it is too large Load Diff