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-