bug-hurd
[Top][All Lists]
Advanced

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

Re: BUG: /proc/self/exe reports relative paths, should always return abs


From: Samuel Thibault
Subject: Re: BUG: /proc/self/exe reports relative paths, should always return absolute paths?
Date: Tue, 26 Sep 2017 16:24:39 +0200
User-agent: NeoMutt/20170113 (1.7.2)

Svante Signell, on mar. 26 sept. 2017 16:15:06 +0200, wrote:
> +       /* Relative path */
> +       else
> +         {
> +           cwd = getcwd (NULL, 0);
> +           if (cwd == NULL)
> +             goto out;
> +
> +           res = asprintf (&concat_name, "%s/%s", cwd, file);

That should be “filename” instead of “file”.

Take the case of PATH containing e.g. :bin: , and your current directory
contains a bin directory which contains a script and you pass only the
name of the script to spawni(). “file” would only contain the name
of the script, while “filename” would contain ./bin/

> +           if (res == -1)
> +             {
> +               free (cwd);

In both cases you can just free(cwd) right after the asprintf call, to
make the whole code simpler, and also make the cwd variable local to the
corresponding blocks.

> +               goto out;
> +             }
> +
> +           filename = concat_name;
> +           break;
> +         }



reply via email to

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