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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Rainer Deyke <rainerd <at> eldwood.com>
Subject: bug#21611: closed (Re: bug#21611: probable bug in tee: tee
 overwrites argv[argc] (coreutils-8.24))
Date: Sun, 04 Oct 2015 00:07:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

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

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 21611 <at> debbugs.gnu.org.

-- 
21611: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21611
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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 3 (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)]
[Message part 5 (message/rfc822, inline)]
From: Rainer Deyke <rainerd <at> eldwood.com>
To: bug-coreutils <at> gnu.org
Subject: probable bug in tee: tee overwrites argv[argc] (coreutils-8.24)
Date: Sat, 3 Oct 2015 11:48:59 +0200
[Message part 6 (text/plain, inline)]
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.  The attached patch replaces the 
current hack with another hack that is still bad style, but probably 
safer than the current hack.


-- 
Rainer Deyke (rainerd <at> eldwood.com)
[patch (text/plain, attachment)]

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

Previous Next


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