From: Dmitry V. Levin Date: Tue, 19 Dec 2017 21:06:23 +0000 (+0000) Subject: elf: remove redundant code from _dl_dst_substitute X-Git-Tag: glibc-2.27~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97f13188c9fbafeaab89146996b3cce1f4952b5e;p=thirdparty%2Fglibc.git elf: remove redundant code from _dl_dst_substitute There are just two users of _dl_dst_substitute: one is expand_dst that sets is_path argument to 0, another one is expand_dynamic_string_token. The latter function also has just two users: one is _dl_map_object that sets is_path argument to 0, another one is fillin_rpath that sets is_path argument to 1 and name argument contains no ':'. In any case (is_path && name[i] == ':') is always false and all code depending on it can be safely removed. * elf/dl-load.c (_dl_dst_substitute): Remove checks that is_path is set and name contains ':', and all code depending on these checks. --- diff --git a/ChangeLog b/ChangeLog index 086bb819562..297dd703c50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-12-27 Dmitry V. Levin + + * elf/dl-load.c (_dl_dst_substitute): Remove checks that is_path + is set and name contains ':', and all code depending on these checks. + 2017-12-24 Zack Weinberg * libio/libio.h, libio/_G_config.h: New stub headers which issue a diff --git a/elf/dl-load.c b/elf/dl-load.c index 29644641585..a60277d311f 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -291,13 +291,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, /* We cannot use this path element, the value of the replacement is unknown. */ wp = last_elem; - name += len; - while (*name != '\0' && (!is_path || *name != ':')) - ++name; - /* Also skip following colon if this is the first rpath - element, but keep an empty element at the end. */ - if (wp == result && is_path && *name == ':' && name[1] != '\0') - ++name; + break; } else /* No DST we recognize. */ @@ -306,19 +300,6 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, else { *wp++ = *name++; - if (is_path && *name == ':') - { - /* In SUID/SGID programs, after $ORIGIN expansion the - normalized path must be rooted in one of the trusted - directories. */ - if (__glibc_unlikely (check_for_trusted) - && !is_trusted_path_normalize (last_elem, wp - last_elem)) - wp = last_elem; - else - last_elem = wp; - - check_for_trusted = false; - } } } while (*name != '\0');