about summary refs log tree commit diff
path: root/elf/sprof.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-10-29 12:51:53 -0400
committerUlrich Drepper <drepper@gmail.com>2011-10-29 12:51:53 -0400
commitc9aafacee48275d85d86f25ab4569516f180846a (patch)
tree4536b3eef5c45350700078df361166215b2b0b9e /elf/sprof.c
parentd272e7f19dc2dae6d215f6ca6512d042575ed736 (diff)
downloadglibc-c9aafacee48275d85d86f25ab4569516f180846a.tar.gz
glibc-c9aafacee48275d85d86f25ab4569516f180846a.tar.xz
glibc-c9aafacee48275d85d86f25ab4569516f180846a.zip
Correctly NUL-terminate link name in sprof
Diffstat (limited to 'elf/sprof.c')
-rw-r--r--elf/sprof.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/elf/sprof.c b/elf/sprof.c
index dbe217b083..069649a654 100644
--- a/elf/sprof.c
+++ b/elf/sprof.c
@@ -596,10 +596,11 @@ load_shobj (const char *name)
       static const char procpath[] = "/proc/self/fd/%d";
       char origprocname[sizeof (procpath) + sizeof (int) * 3];
       snprintf (origprocname, sizeof (origprocname), procpath, fd);
-      char *origlink = (char *) alloca (PATH_MAX + 1);
-      origlink[PATH_MAX] = '\0';
-      if (readlink (origprocname, origlink, PATH_MAX) == -1)
+      char *origlink = (char *) alloca (PATH_MAX);
+      ssize_t n = readlink (origprocname, origlink, PATH_MAX)
+      if (n == -1)
 	goto no_debuginfo;
+      origlink[n] = '\0';
 
       /* Try to find the actual file.  There are three places:
 	 1. the same directory the DSO is in