GNU bug report logs - #21611
probable bug in tee: tee overwrites argv[argc] (coreutils-8.24)

Previous Next

Package: coreutils;

Reported by: Rainer Deyke <rainerd <at> eldwood.com>

Date: Sat, 3 Oct 2015 13:25:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 21611-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Rainer Deyke <rainerd <at> eldwood.com>, 21611-done <at> debbugs.gnu.org
Subject: Re: bug#21611: probable bug in tee: tee overwrites argv[argc]
 (coreutils-8.24)
Date: Sat, 3 Oct 2015 17:06:52 -0700
[Message part 1 (text/plain, inline)]
Rainer Deyke wrote:
> As mentioned in a comment on line 198 of 'tee.c', 'tee' overwrites
> 'argv[argc]'.  This is very bad style at best, and probably undefined behavior
> on at least some platforms.

Thanks for the report.  It's well-defined behavior on any platform conforming to 
the C standard, so it should be quite safe.  That being said, it's a bit faster 
to subtract 1 from a pointer than to do the equivalent of a memmove of an array, 
so it sounds a bit faster to do things the way you suggest.  Cleaner, too.  I 
installed the attached patch.
[0001-tee-simplify-argv-handling.patch (text/plain, attachment)]

This bug report was last modified 9 years and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.