bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] Fix /proc/*/cmdline.


From: olafBuddenhagen
Subject: Re: [PATCH 1/2] Fix /proc/*/cmdline.
Date: Fri, 13 Aug 2010 17:13:20 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

On Fri, Aug 13, 2010 at 06:06:41AM +0200, Jeremie Koenig wrote:

> On Linux, the per-process cmdline files should include the whole command line,
> with subsequent arguments separated by NUL bytes. However, for some reason we
> used to truncate it after the first one and append " \n".

Hm... As far as I can see, you actually fixed two bugs here: the
completely wrong handling of the actual data; and wrong/missing error
handling. I'm not sure if it's worth splitting into separate patches --
but it should be reflected in the commit message...

>    err = set_field_value (ps, PSTAT_ARGS);
> +  if (err)
> +    goto out;
>  
> -  if (! err)
> -    if (asprintf (&cmdline_data, "%s \n", ps->args) == -1)
> -      return errno;
> -
> -  memcpy (data, cmdline_data, strlen(cmdline_data));
> -  *len = strlen (data);
> +  memcpy (data, ps->args, ps->args_len);
> +  *len = ps->args_len;
>  
> +out:
>    _proc_stat_free (ps); 
> -  free (cmdline_data);
>    return err;
>  }

Actually, using an "if (!err)" block (i.e. like the original code, minus
bugs) would be much nicer here IMHO...

-antrik-



reply via email to

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