[PATCH][v2] Add dynamic linker support for $EXEC_ORIGIN.

Brooks Moses bmoses@google.com
Thu Dec 12 22:42:00 GMT 2013


On Thu, Dec 12, 2013 at 2:21 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Thu, Dec 12, 2013 at 2:13 PM, Brooks Moses <bmoses@google.com> wrote:
>> +static char *
>> +get_directory (const char *file_path)
>> +{
>> +  assert (file_path != NULL);
>
> This can definitely be called with NULL file_path (if e.g. the kernel
> doesn't supply AT_EXECFN), so assert() doesn't seem appropriate here.

Not quite true.  Although the overall code can be called with a NULL
file path, get_directory() is a subsidiary function that is only
called when it's non-null.  All of the calls to it should go through
set_exec_origin_path(), and the line there that calls it is guarded by
a non-NULL check:

  else if (exe_path != NULL)
    GLRO(dl_exec_origin_path) = get_directory (exe_path);

- Brooks



More information about the Libc-alpha mailing list