about summary refs log tree commit diff
path: root/elf/dl-object.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-object.c')
-rw-r--r--elf/dl-object.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/elf/dl-object.c b/elf/dl-object.c
index 0488e3230c..398628aa1b 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;