[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] little bug in tar
From: |
Klaus Stehle |
Subject: |
[Bug-tar] little bug in tar |
Date: |
Wed, 21 Apr 2004 09:31:58 +0200 (CEST) |
Hallo Paul Eggert or others,
There is a little bug in tar version >= 1.13.18
It appears when you set the environment variable TAR_OPTIONS to something
and use the old-style command line like
tar xvf blablabla.tar
_without_ the '-' sign.
The problem is that the 'old-style ==> new-style'-conversion routine
(function decode_options() in file tar.c)
doesn't copy the very last element argv[argc],
which _should_ be a NULL pointer.
The following function prepend_default_options() relies on this
last NULL pointer and continues copying pointers of argv which don't
exist, so that tar crashes.
Here is the patch for the old-style-to-new-style-conversion routine in tar.c
--- src/tar.c.orig 2002-05-17 02:21:16.000000000 +0100
+++ src/tar.c 2004-04-15 19:38:30.342443200 +0100
@@ -534,7 +534,7 @@
/* Allocate a new argument array, and copy program name in it. */
new_argc = argc - 1 + strlen (argv[1]);
- new_argv = xmalloc (new_argc * sizeof (char *));
+ new_argv = xmalloc ((new_argc + 1) * sizeof (char *));
in = argv;
out = new_argv;
*out++ = *in++;
@@ -559,7 +559,7 @@
/* Copy all remaining options. */
- while (in < argv + argc)
+ while (in <= argv + argc)
*out++ = *in++;
/* Replace the old option list by the new one. */
Cheers,
Klaus
- [Bug-tar] little bug in tar,
Klaus Stehle <=