1
0
mirror of https://repo.or.cz/libtar.git synced 2025-04-18 05:04:01 +03:00

51 Commits

Author SHA1 Message Date
Tim Band
6d0ab4c78e Added autoconf instructions to README 2013-12-08 16:09:21 -05:00
Ron Yorston
aa263f13f3 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
2013-11-18 00:32:42 -05:00
Chris Frey
e4c1f29742 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
2013-11-18 00:28:36 -05:00
Kamil Dudka
7c3b3453bf .gitignore: ignore binaries and generated files 2013-10-25 18:22:26 -04:00
Chris Frey
20aa09bd77 Added stdlib.h for malloc() in lib/decode.c 2013-10-24 17:58:47 -04:00
Chris Frey
495d0c0eab Check for NULL before freeing th_pathname
Thanks to Harald Koch for pointing out that AIX 4 and 5 still need this.
2013-10-24 17:55:12 -04:00
Kamil Dudka
ec613af2e9 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.
2013-10-24 17:54:08 -04:00
Huzaifa Sidhpurwala
f3c711cf30 fix memleaks in libtar sample program 2013-10-15 20:05:04 -04:00
Huzaifa Sidhpurwala
36629a4120 fix memleak on tar_open() failure 2013-10-15 20:02:58 -04:00
Kamil Dudka
abd0274e6b fix file descriptor leaks reported by cppcheck
Bug: https://bugzilla.redhat.com/785760
2013-10-15 19:48:41 -04:00
Huzaifa Sidhpurwala
560911b694 Fix invalid memory de-reference issue
Bug: https://bugzilla.redhat.com/551415

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
2013-10-15 19:14:24 -04:00
Hans de Goede
30e5556d1c Fix missing prototype compiler warnings
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
2013-10-15 19:14:05 -04:00
Chris Frey
8128ad8c79 Added commentary on T_BLOCKSIZE, ssize_t, and int size risks
Thanks to Chris Palmer.
2013-10-10 19:55:06 -04:00
Chris Frey
0907a9034e libtar version 1.2.20 v1.2.20 2013-10-09 12:59:44 -04:00
Chris Frey
45448e8bae Fixed size_t overflow bug, as reported by Timo Warns 2013-10-01 16:45:34 -04:00
Chris Frey
a4846f7e86 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.
2013-03-29 02:09:08 -04:00
Sergey Zhitomirsky
79f6bec843 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.
2013-03-29 01:33:08 -04:00
Chris Frey
9e771b20e7 Added extern "C" protectors to listhash.h
Thanks to Marcin Adamski for the report!
2013-02-03 22:16:27 -05:00
Chris Frey
f06ab1aef1 libtar version 1.2.19 v1.2.19 2012-12-11 18:29:59 -05:00
Jan Cermak
d0fe11d76c Added const to char* function arguments where appropriate 2012-12-11 17:41:49 -05:00
Chris Frey
aef9ecd42a 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.
2012-09-05 15:43:02 -04:00
Chris Frey
4604797bb5 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'
2012-09-05 15:26:02 -04:00
Chris Frey
533ad503fe 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
2012-09-05 15:25:16 -04:00
Chris Frey
eb706c362c 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.
2012-09-05 15:23:49 -04:00
Chris Frey
e34b225cd1 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.
v1.2.18
2012-08-02 16:47:19 -04:00
Chris Frey
e44cab4de6 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."
2012-07-31 17:12:36 -04:00
Chris Frey
acd507bfd1 libtar version 1.2.17 v1.2.17 2012-07-24 17:06:43 -04:00
Tim Band
7611cc65f4 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.
2012-07-24 16:51:42 -04:00
Chris Frey
063f8f6f0b libtar version 1.2.16 v1.2.16 2012-05-17 03:34:32 -04:00
Chris Frey
e8adb5e6ce 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.
2012-05-17 03:31:12 -04:00
Chris Frey
29ccc47958 libtar version 1.2.15 v1.2.15 2012-05-10 01:14:18 -04:00
Chris Frey
258c26f444 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.
2012-05-10 01:08:07 -04:00
Chris Frey
4331cced90 libtar version 1.2.14 v1.2.14 2011-12-22 17:13:36 -05:00
Chris Frey
f6c704837d 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.
2011-12-22 17:08:28 -05:00
Chris Frey
11df82507d libtar version 1.2.13 v1.2.13 2011-06-13 18:23:23 -04:00
Per Lidén
20f460bd4d 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
2011-06-13 17:57:16 -04:00
Per Lidén
fcb6cd7be4 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
2011-06-13 17:56:56 -04:00
Magnus Holmgren
95946f38a7 Escape hyphens that should be minus signs in man pages. 2011-06-13 17:35:50 -04:00
Glenn McGrath
26d694fe4f Use libtool to build dynamic library 2011-06-13 17:31:57 -04:00
Chris Frey
ef1f0d41aa 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.
2011-06-13 17:25:44 -04:00
James Morrison
e0adfa69dc 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.)
2011-06-06 18:40:06 -04:00
Chris Frey
c89c03aeca Applied Marcin Gibula's patch fixing tar_extract_glob()
https://lists.feep.net:8080/pipermail/libtar/2003-September/000160.html
2009-05-02 01:23:57 -04:00
Chris Frey
d881966c92 Fixed header warnings 2009-05-02 00:03:33 -04:00
Chris Frey
b50447bef6 Added datarootdir to Makefile.in's 2009-05-01 23:57:00 -04:00
Chris Frey
fdffae09bb Removed auto-generated files 2009-05-01 23:39:56 -04:00
Chris Frey
ac0ed32dcb Removed m4 includes, and straightened out [] m4 quoting for modern autoconfs 2009-05-01 23:39:44 -04:00
Chris Frey
3f1e07b5b0 Renamed autoconf/aclocal.m4 to psg.m4 so aclocal isn't so confused 2009-05-01 23:39:36 -04:00
Chris Frey
9added7d64 Added autogen.sh script to build a fresh configure 2009-05-01 23:39:26 -04:00
Chris Frey
f90a067c44 Added autoconf/ as macro dir 2009-05-01 23:39:26 -04:00
Chris Frey
a9aa57754d Fixed incorrect URL in readme
Patch from Joni Yrjn
https://lists.feep.net:8080/pipermail/libtar/2006-July/000228.html
2009-04-28 16:39:21 -04:00