]> git.ipfire.org Git - thirdparty/glibc.git/commit
elf: Check for empty tokens before dynamic string token expansion [BZ #22625]
authorAurelien Jarno <aurelien@aurel32.net>
Sat, 30 Dec 2017 09:54:23 +0000 (10:54 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 31 Dec 2017 12:07:11 +0000 (13:07 +0100)
commitf24c345bf5486cc8d659f7a17463adcae402ec8e
treeccad5ed25f2bdcec2b8250af48772d3694f7b229
parent248475457e40d44b12f1f69c889765bba4571add
elf: Check for empty tokens before dynamic string token expansion [BZ #22625]

The fillin_rpath function in elf/dl-load.c loops over each RPATH or
RUNPATH tokens and interprets empty tokens as the current directory
("./"). In practice the check for empty token is done *after* the
dynamic string token expansion. The expansion process can return an
empty string for the $ORIGIN token if __libc_enable_secure is set
or if the path of the binary can not be determined (/proc not mounted).

Fix that by moving the check for empty tokens before the dynamic string
token expansion. In addition, check for NULL pointer or empty strings
return by expand_dynamic_string_token.

The above changes highlighted a bug in decompose_rpath, an empty array
is represented by the first element being NULL at the fillin_rpath
level, but by using a -1 pointer in decompose_rpath and other functions.

Changelog:
[BZ #22625]
* elf/dl-load.c (fillin_rpath): Check for empty tokens before dynamic
string token expansion. Check for NULL pointer or empty string possibly
returned by expand_dynamic_string_token.
(decompose_rpath): Check for empty path after dynamic string
token expansion.
(cherry picked from commit 3e3c904daef69b8bf7d5cc07f793c9f07c3553ef)
ChangeLog
NEWS
elf/dl-load.c