[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Use strdup in dd to avoid changing argv elements
From: |
Eric Blake |
Subject: |
Re: [PATCH] Use strdup in dd to avoid changing argv elements |
Date: |
Mon, 28 Jan 2008 06:44:44 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jim Meyering on 1/28/2008 6:28 AM:
|
| Thanks for the suggestion, but that introduces a new way for
| dd to fail: strdup returning NULL would often lead to a segfault.
| Even if it were to use xstrdup, to avoid that, I don't think it's
| justifiable solely in order to preserve ps' view of the dd command line.
However, it IS justifiable by the fact that POSIX requires applications to
treat argv[] as constant (ie. modifying argv in-place is not
standards-compliant). True, most systems let you get away with
modifications (in particular, think about getopt_long's behavior), but it
would matter if we ever port coreutils to a system that follows the POSIX
permission to insist on no modifications to the original argv and contents.
http://www.opengroup.org/onlinepubs/009695399/functions/execl.html
"The statement about argv[] and envp[] being constants is included to make
explicit to future writers of language bindings that these objects are
completely constant. Due to a limitation of the ISO C standard, it is not
possible to state that idea in standard C."
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHndxM84KuGfSFAYARAs3KAKCxWmw5NFWQJON3I683GauhAkczWgCfXmrv
gXNRWZ9coMJIbEcBOH7GX+8=
=1fIr
-----END PGP SIGNATURE-----
- [PATCH] Use strdup in dd to avoid changing argv elements, Adam Goode, 2008/01/28
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Jim Meyering, 2008/01/28
- Re: [PATCH] Use strdup in dd to avoid changing argv elements,
Eric Blake <=
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Jim Meyering, 2008/01/28
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Andreas Schwab, 2008/01/28
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Paul Eggert, 2008/01/29
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Jim Meyering, 2008/01/30
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Paul Eggert, 2008/01/30
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Jim Meyering, 2008/01/31
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Andreas Schwab, 2008/01/28
- Re: [PATCH] Use strdup in dd to avoid changing argv elements, Eric Blake, 2008/01/28