bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Use strdup in dd to avoid changing argv elements


From: Jim Meyering
Subject: Re: [PATCH] Use strdup in dd to avoid changing argv elements
Date: Mon, 28 Jan 2008 14:28:27 +0100

Adam Goode <address@hidden> wrote:
> Right now, dd uses strchr to do some parsing of argv. This messes up how
> dd appears in ps.
>
> Here is a very simple solution to this problem. Yes, it does not free
> memory. But does it matter? dd is just a standalone application.
...
> diff --git a/src/dd.c b/src/dd.c
> index cc1ba0c..b8ab8a9 100644
> --- a/src/dd.c
> +++ b/src/dd.c
> @@ -877,7 +877,7 @@ scanargs (int argc, char **argv)
>      {
>        char *name, *val;
>
> -      name = argv[i];
> +      name = strdup(argv[i]);
>        val = strchr (name, '=');
>        if (val == NULL)
>       {

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]