From 0f861584a5e50e6a052cd15f1f3c1c78c0d7d401 Mon Sep 17 00:00:00 2001 From: David Rhodus Date: Sun, 27 Jul 2003 03:20:17 +0000 Subject: [PATCH] Null terminate the new argv[] array when converting 'tar zcf' to 'tar -z -c -f' --- contrib/tar/src/tar.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/tar/src/tar.c b/contrib/tar/src/tar.c index 33d6574ab0..b71732ac2a 100644 --- a/contrib/tar/src/tar.c +++ b/contrib/tar/src/tar.c @@ -20,7 +20,7 @@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* $FreeBSD: src/contrib/tar/src/tar.c,v 1.2.2.1 2002/07/14 13:19:44 sobomax Exp $ */ -/* $DragonFly: src/contrib/tar/src/Attic/tar.c,v 1.2 2003/06/17 04:24:06 dillon Exp $ */ +/* $DragonFly: src/contrib/tar/src/Attic/tar.c,v 1.3 2003/07/27 03:20:17 drhodus Exp $ */ #include "system.h" @@ -550,7 +550,7 @@ decode_options (int argc, char **argv) /* 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++; @@ -578,6 +578,9 @@ decode_options (int argc, char **argv) while (in < argv + argc) *out++ = *in++; + /* And NULL terminate the argv[] array */ + *out++ = NULL; + /* Replace the old option list by the new one. */ argc = new_argc; -- 2.41.0