libtar.git
10 years agoAdded autoconf instructions to READMEmaster
Tim Band [Tue, 3 Dec 2013 14:31:11 +0000 (3 14:31 +0000)]
Added autoconf instructions to README

10 years agoOpen files in binary mode on systems that have O_BINARY
Ron Yorston [Wed, 13 Nov 2013 10:06:47 +0000 (13 10:06 +0000)]
Open files in binary mode on systems that have O_BINARY

There are three places in the library where files are opened.  In two
of those places the flag O_BINARY is included if defined.  This patch
does the same in the third.

I noticed this because I've been using (a hacked version of) the library
cross-compiled with MinGW on WIN32.  I expect Cygwin would also be
affected.

Ron

10 years agoChange th_get_size() macro to return unsigned int
Chris Frey [Thu, 24 Oct 2013 22:52:44 +0000 (24 18:52 -0400)]
Change th_get_size() macro to return unsigned int

On systems where size_t is larger than an int (and larger than
unsigned int), then in various places in the library, where
stuff like this happens:

size_t sz = th_get_size(t);

then the int value returned from th_get_size() is sign extended to
some unwieldy amount.

On 64bit systems, this can yield extremely large values.

By fixing this problem in the header, and only for th_get_size(),
we avoid breaking the API of the function call oct_to_int()
(which arguably should return an unsigned int, since the sscanf()
it uses expects to yield an unsigned int).  We also fix the library,
which uses th_get_size() internally to assign sizes to size_t.

The drawback is that not all client code that uses th_get_size()
will be fixed, until they recompile, but they will automatically
take advantage of the bugs fixed *inside* the library.

The remaining th_get_*() functions operate on modes and CRC values
and the like, and should be fine, remaining as ints.

Thanks very much to Magnus Holmgren for catching this behaviour.
https://lists.feep.net:8080/pipermail/libtar/2013-October/000365.html

10 years ago.gitignore: ignore binaries and generated files
Kamil Dudka [Fri, 25 Oct 2013 11:49:58 +0000 (25 13:49 +0200)]
.gitignore: ignore binaries and generated files

10 years agoAdded stdlib.h for malloc() in lib/decode.c
Chris Frey [Thu, 24 Oct 2013 21:58:47 +0000 (24 17:58 -0400)]
Added stdlib.h for malloc() in lib/decode.c

10 years agoCheck for NULL before freeing th_pathname
Chris Frey [Thu, 24 Oct 2013 21:55:12 +0000 (24 17:55 -0400)]
Check for NULL before freeing th_pathname

Thanks to Harald Koch for pointing out that AIX 4 and 5 still need this.

10 years agodecode: avoid using a static buffer in th_get_pathname()
Kamil Dudka [Wed, 23 Oct 2013 13:04:22 +0000 (23 15:04 +0200)]
decode: avoid using a static buffer in th_get_pathname()

A solution suggested by Chris Frey:
https://lists.feep.net:8080/pipermail/libtar/2013-October/000377.html

Note this can break programs that expect sizeof(TAR) to be fixed.

10 years agofix memleaks in libtar sample program
Huzaifa Sidhpurwala [Wed, 16 Oct 2013 00:05:04 +0000 (15 20:05 -0400)]
fix memleaks in libtar sample program

10 years agofix memleak on tar_open() failure
Huzaifa Sidhpurwala [Wed, 16 Oct 2013 00:02:58 +0000 (15 20:02 -0400)]
fix memleak on tar_open() failure

10 years agofix file descriptor leaks reported by cppcheck
Kamil Dudka [Tue, 15 Oct 2013 23:48:41 +0000 (15 19:48 -0400)]
fix file descriptor leaks reported by cppcheck

Bug: https://bugzilla.redhat.com/785760

10 years agoFix invalid memory de-reference issue
Huzaifa Sidhpurwala [Tue, 15 Oct 2013 12:39:05 +0000 (15 14:39 +0200)]
Fix invalid memory de-reference issue

Bug: https://bugzilla.redhat.com/551415

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
10 years agoFix missing prototype compiler warnings
Hans de Goede [Tue, 15 Oct 2013 12:39:04 +0000 (15 14:39 +0200)]
Fix missing prototype compiler warnings

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
10 years agoAdded commentary on T_BLOCKSIZE, ssize_t, and int size risks
Chris Frey [Thu, 10 Oct 2013 23:55:06 +0000 (10 19:55 -0400)]
Added commentary on T_BLOCKSIZE, ssize_t, and int size risks

Thanks to Chris Palmer.

10 years agolibtar version 1.2.20v1.2.20
Chris Frey [Wed, 9 Oct 2013 16:55:48 +0000 (9 12:55 -0400)]
libtar version 1.2.20

10 years agoFixed size_t overflow bug, as reported by Timo Warns
Chris Frey [Tue, 1 Oct 2013 19:58:52 +0000 (1 15:58 -0400)]
Fixed size_t overflow bug, as reported by Timo Warns

11 years agoAdded autoconf checks for __thread compiler support
Chris Frey [Fri, 29 Mar 2013 05:38:36 +0000 (29 01:38 -0400)]
Added autoconf checks for __thread compiler support

If the compiler does not support __thread or __declspec(thread)
as tested for in autoconf/ax_tls.m4, then libtar is not as threadsafe
as you may expect.

11 years agoFixed thread-safe bug in th_get_pathname()
Sergey Zhitomirsky [Fri, 29 Mar 2013 05:33:08 +0000 (29 01:33 -0400)]
Fixed thread-safe bug in th_get_pathname()

Current libtar breaks in multi-thread app, when reading more then 1
tar simultaneously in different threads, one thread may erroneously
receive the filename for the other thread due to returned static
variable.

This bug was was introduced with the patch with the name "Fix memory
leak in th_get_pathname", which removed strdup() from
th_get_pathname() and made filename static.

11 years agoAdded extern "C" protectors to listhash.h
Chris Frey [Mon, 4 Feb 2013 03:16:27 +0000 (3 22:16 -0500)]
Added extern "C" protectors to listhash.h

Thanks to Marcin Adamski for the report!

11 years agolibtar version 1.2.19v1.2.19
Chris Frey [Tue, 11 Dec 2012 23:29:59 +0000 (11 18:29 -0500)]
libtar version 1.2.19

11 years agoAdded const to char* function arguments where appropriate
Jan Cermak [Tue, 11 Dec 2012 22:41:49 +0000 (11 17:41 -0500)]
Added const to char* function arguments where appropriate

11 years agoChanged makedev() argument count test from AC_RUN_ to AC_COMPILE_
Chris Frey [Wed, 5 Sep 2012 19:43:02 +0000 (5 15:43 -0400)]
Changed makedev() argument count test from AC_RUN_ to AC_COMPILE_

See https://lists.feep.net:8080/pipermail/libtar/2012-September/000337.html
for the discussion that lead to this change.

11 years agoFixed gcc compiler built-in warnings
Chris Frey [Wed, 5 Sep 2012 19:26:02 +0000 (5 15:26 -0400)]
Fixed gcc compiler built-in warnings

../compat/snprintf.c:496: warning: conflicting types for built-in function 'pow10'
../compat/snprintf.c:509: warning: conflicting types for built-in function 'round'

11 years agoFixed short int / int compiler warnings in va_arg() usage
Chris Frey [Wed, 5 Sep 2012 19:25:16 +0000 (5 15:25 -0400)]
Fixed short int / int compiler warnings in va_arg() usage

Compiler warned:

../compat/snprintf.c:232: warning: 'short int' is promoted to 'int' when passed through '...'
../compat/snprintf.c:232: note: (so you should pass 'int' not 'short int' to 'va_arg')
../compat/snprintf.c:232: note: if this code is reached, the program will abort

11 years agoRemoved varargs.h and all dependencies on it
Chris Frey [Wed, 5 Sep 2012 19:23:49 +0000 (5 15:23 -0400)]
Removed varargs.h and all dependencies on it

Even configure itself assumes stdarg.h by now in its own tests, at least
on my system, so don't bother with the extra checks anymore, since they
are causing trouble during user compiles.

11 years agolibtar version 1.2.18v1.2.18
Chris Frey [Thu, 2 Aug 2012 20:43:39 +0000 (2 16:43 -0400)]
libtar version 1.2.18

Note: If your application uses the macro th_crc_ok(), then to gain full
advantage of the changes in this version, you will need to recompile
your application against the new headers.  Otherwise, the library is
drop-in replaceable, as usual.

11 years agoAdded more forgiving CRC checking logic when reading tar files
Chris Frey [Tue, 31 Jul 2012 21:12:36 +0000 (31 17:12 -0400)]
Added more forgiving CRC checking logic when reading tar files

Tim Kientzle posted the following to the libtar mailing list regarding
the earlier CRC bug:

This exact bug has reappeared many times in different
tar implementations.  Here are two suggestions:

* The standards specify that the checksum is
calculated using unsigned characters.

* The most robust tar readers will compute the
checksum both ways (with unsigned characters and
with signed characters) and accept the header
if either version matches.

https://lists.feep.net:8080/pipermail/libtar/2012-July/000327.html

He gave the following links:

http://pubs.opengroup.org/onlinepubs/9699919799/

"pax" is under "Shell & Utilities" => "Utilities"; here's
a direct link:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html
https://github.com/libarchive/libarchive/wiki/ManPageTar5

This commit turns libtar into a "more robust tar reader."

11 years agolibtar version 1.2.17v1.2.17
Chris Frey [Tue, 24 Jul 2012 21:06:43 +0000 (24 17:06 -0400)]
libtar version 1.2.17

11 years agoFixed checksum calculation in writing header
Tim Band [Mon, 23 Jul 2012 18:40:40 +0000 (23 19:40 +0100)]
Fixed checksum calculation in writing header

Calculation used signed char instead of unsigned char.
Fixed it by calling the same routine used in reading and checking.

11 years agolibtar version 1.2.16v1.2.16
Chris Frey [Thu, 17 May 2012 07:34:32 +0000 (17 03:34 -0400)]
libtar version 1.2.16

11 years agoFixed build system to allow for out-of-source tree builds
Chris Frey [Thu, 17 May 2012 07:31:12 +0000 (17 03:31 -0400)]
Fixed build system to allow for out-of-source tree builds

When using configure from a directory other than the top level source
tree, there was trouble compiling the compat/ and listhash/ libraries.
Two minor path fixes changed that.

11 years agolibtar version 1.2.15v1.2.15
Chris Frey [Thu, 10 May 2012 05:14:18 +0000 (10 01:14 -0400)]
libtar version 1.2.15

11 years agoFixed harmless buffer overflow which is caught by FORTIFY on some systems
Chris Frey [Thu, 10 May 2012 05:08:07 +0000 (10 01:08 -0400)]
Fixed harmless buffer overflow which is caught by FORTIFY on some systems

encode.c takes a shortcut, and updates two struct fields with one
strncpy() call.  This commit splits it into two calls.

12 years agolibtar version 1.2.14v1.2.14
Chris Frey [Thu, 22 Dec 2011 22:13:36 +0000 (22 17:13 -0500)]
libtar version 1.2.14

12 years agoFixed truncation check, so 100 char names get GNU extension support when enabled
Chris Frey [Thu, 22 Dec 2011 22:08:28 +0000 (22 17:08 -0500)]
Fixed truncation check, so 100 char names get GNU extension support when enabled

Reported by Barrie Walker as follows:

I've experienced a problem with 1.2.11 where a name or link is exactly
100 characters.

When not using TAR_GNU name/linknames longer than 99 characters are
simply truncated to 99 characters (+1 for the NUL makes T_NAMELEN (=
100)). Any overflow is lost - fair enough.

Using TAR_GNU, name/linknames longer than 99 characters are still
truncated to 99 characters but the full string is placed in the
gnu_longname/gnu_longlink fields.
However the gnu_longname/gnu_longlink fields are populated only when a
name/linkname would be truncated.

The bug is that the check to see whether there will be truncation
compares the length against T_NAMELEN rather than T_NAMELEN-1.

The fix is simply, in lines 85 and 123 of encode.c, to change T_NAMELEN
to T_NAMELEN-1.

12 years agolibtar version 1.2.13v1.2.13
Chris Frey [Mon, 13 Jun 2011 22:21:35 +0000 (13 18:21 -0400)]
libtar version 1.2.13

12 years agoReduce memory used by libtar when extracting files.
Per Lidén [Mon, 13 Jun 2011 21:51:37 +0000 (13 17:51 -0400)]
Reduce memory used by libtar when extracting files.

The patch below drastically reduces the amount of memory used by libtar
when extracting files. For each extracted file a 8K struct (MAXPATHLEN is
4096 in Linux) is allocated and inserted in the hashtable for hardlink
mapping. However, in the normal case only a tiny part of those 8K is used.
The patch below calculates the size and allocates no more memory than
needed.

When I unpacked a tar with ~550 files, the memory consumption for the
hashtable went from about 4Mb down to about 200Kb.

/Per

https://lists.feep.net:8080/pipermail/libtar/2003-October/000162.html

12 years agoFix memory leak in th_get_pathname
Per Lidén [Mon, 13 Jun 2011 21:46:05 +0000 (13 17:46 -0400)]
Fix memory leak in th_get_pathname

Fix memory leak in th_get_pathname by making the buffer, where prefix
and filename are concatenated, static and returning that instead of a
pointer to a copy of a local buffer.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libtar/+bug/41804
https://lists.feep.net:8080/pipermail/libtar/2003-October/000161.html

12 years agoEscape hyphens that should be minus signs in man pages.
Magnus Holmgren [Mon, 13 Jun 2011 21:35:50 +0000 (13 17:35 -0400)]
Escape hyphens that should be minus signs in man pages.

12 years agoUse libtool to build dynamic library
Glenn McGrath [Mon, 13 Jun 2011 21:31:57 +0000 (13 17:31 -0400)]
Use libtool to build dynamic library

12 years agoChanged root Makefile.in to Makefile.am, which make autoreconf workable
Chris Frey [Mon, 13 Jun 2011 21:23:58 +0000 (13 17:23 -0400)]
Changed root Makefile.in to Makefile.am, which make autoreconf workable

Running autoreconf without errors, and using a custom autoconf directory,
means that automake features are used, in order to find that autoconf
directory.  This cleans up the root build system to make it less
surprising to maintainers.

12 years agoDocument stupidity of tartype_t in libtar.c.
James Morrison [Mon, 6 Jun 2011 22:40:06 +0000 (6 18:40 -0400)]
Document stupidity of tartype_t in libtar.c.

Bug-Debian: http://bugs.debian.org/309945

(Patch taken from Debian packaging by Chris Frey, and editied slightly
to remove extra header include.)

14 years agoApplied Marcin Gibula's patch fixing tar_extract_glob()
Chris Frey [Sat, 2 May 2009 05:23:57 +0000 (2 01:23 -0400)]
Applied Marcin Gibula's patch fixing tar_extract_glob()

https://lists.feep.net:8080/pipermail/libtar/2003-September/000160.html

14 years agoFixed header warnings
Chris Frey [Sat, 2 May 2009 04:03:33 +0000 (2 00:03 -0400)]
Fixed header warnings

14 years agoAdded datarootdir to Makefile.in's
Chris Frey [Sat, 2 May 2009 03:57:00 +0000 (1 23:57 -0400)]
Added datarootdir to Makefile.in's

14 years agoRemoved auto-generated files
Chris Frey [Wed, 29 Apr 2009 08:44:29 +0000 (29 04:44 -0400)]
Removed auto-generated files

14 years agoRemoved m4 includes, and straightened out [] m4 quoting for modern autoconfs
Chris Frey [Sat, 2 May 2009 03:36:44 +0000 (1 23:36 -0400)]
Removed m4 includes, and straightened out [] m4 quoting for modern autoconfs

14 years agoRenamed autoconf/aclocal.m4 to psg.m4 so aclocal isn't so confused
Chris Frey [Sat, 2 May 2009 03:36:06 +0000 (1 23:36 -0400)]
Renamed autoconf/aclocal.m4 to psg.m4 so aclocal isn't so confused

14 years agoAdded autogen.sh script to build a fresh configure
Chris Frey [Sat, 2 May 2009 03:18:48 +0000 (1 23:18 -0400)]
Added autogen.sh script to build a fresh configure

14 years agoAdded autoconf/ as macro dir
Chris Frey [Sat, 2 May 2009 03:02:45 +0000 (1 23:02 -0400)]
Added autoconf/ as macro dir

14 years agoFixed incorrect URL in readme
Chris Frey [Tue, 28 Apr 2009 20:39:21 +0000 (28 16:39 -0400)]
Fixed incorrect URL in readme

Patch from Joni Yrjänä
https://lists.feep.net:8080/pipermail/libtar/2006-July/000228.html

14 years agolibtar-1.2.11 tarball sources, taken from Debian's orig tarv1.2.11
Chris Frey [Tue, 28 Apr 2009 20:35:00 +0000 (28 16:35 -0400)]
libtar-1.2.11 tarball sources, taken from Debian's orig tar

The main site, feep.net, has a broken ftp link, so can't download
tarball from there.