aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-02 20:17:54 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-02 20:17:54 +0000
commit88794e308552d6051453544f8790986314fd9e1c (patch)
tree7811ea4e234dd21b1a49424ecfaaf95bda52e7b6 /elf
parent1e823b7d2dcbffb793be1e48b397d7c1a1b19a52 (diff)
downloadglibc-88794e308552d6051453544f8790986314fd9e1c.zip
glibc-88794e308552d6051453544f8790986314fd9e1c.tar.gz
glibc-88794e308552d6051453544f8790986314fd9e1c.tar.bz2
Update.
* elf/dl-object.c (_dl_new_object): Avoid using strrchr. We have more information. * elf/rtld.c (dl_main): Avoid strrchr. * sysdeps/unix/sysv/linux/dl-origin.c (_dl_get_origin): Use the result of readlink. Search from the back for '/'.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-object.c15
-rw-r--r--elf/rtld.c13
2 files changed, 19 insertions, 9 deletions
diff --git a/elf/dl-object.c b/elf/dl-object.c
index 0488e32..398628a 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -150,15 +150,18 @@ _dl_new_object (char *realname, const char *libname, int type,
}
/* Add the real file name. */
- memcpy (cp, realname, realname_len);
+ cp = __mempcpy (cp, realname, realname_len);
- /* Now remove the filename and the slash. Leave the slash if it
+ /* Now remove the filename and the slash. Leave the slash if
the name is something like "/foo". */
- cp = strrchr (origin, '/');
+ do
+ --cp;
+ while (*cp != '/');
+
if (cp == origin)
- origin[1] = '\0';
- else
- *cp = '\0';
+ /* Keep the only slash which is the first character. */
+ ++cp;
+ *cp = '\0';
out:
new->l_origin = origin;
diff --git a/elf/rtld.c b/elf/rtld.c
index 1efe38b..b835bd5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -589,10 +589,17 @@ of this helper program; chances are you did not intend to run this program.\n\
be our SONAME, and add it to our name list. */
if (GL(dl_rtld_map).l_ld == NULL)
{
- char *p = strrchr (_dl_rtld_libname.name, '/');
- if (p)
+ const char *p = NULL;
+ const char *cp = _dl_rtld_libname.name;
+
+ /* Find the filename part of the path. */
+ while (*cp != '\0')
+ if (*cp++ == '/')
+ p = cp;
+
+ if (p != NULL)
{
- _dl_rtld_libname2.name = p+1;
+ _dl_rtld_libname2.name = p;
/* _dl_rtld_libname2.next = NULL; Already zero. */
_dl_rtld_libname.next = &_dl_rtld_libname2;
}