[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug#192537: sort segfaults with argv[0] = NULL
From: |
Jim Meyering |
Subject: |
Re: Bug#192537: sort segfaults with argv[0] = NULL |
Date: |
Sun, 11 May 2003 11:20:51 +0200 |
Paul Eggert <address@hidden> wrote:
> Jim Meyering <address@hidden> writes:
>
>> You're probably already aware that very many programs assume that
>> `argc' is always 1 or larger, and hence dereference argv[0]
>> unconditionally.
>
> POSIX requires that any Strictly Conforming POSIX Application must
> pass at least one argument to the exec function family, thus
> guaranteeing that argv[0] can be dereferenced unconditionally in the
> exec'ed program. See the RATIONALE section of
> <http://www.opengroup.org/onlinepubs/007904975/functions/exec.html>.
I noticed that, too, but went ahead and changed many of the
programs in coreutils regardless. I found and fixed a few other
minor problems in the process, so it wasn't for naught.
> I suppose it's a bit nicer if programs work even when argv[0] is NULL,
> but this would require hacking a lot of code, and it sounds a bit like
> makework to me. So, like Jim, I'm curious as to the motivation for
> this bug report.
He said privately that a friend noticed the problem when attempting
to exec sort with no command line arguments.