From c9aafacee48275d85d86f25ab4569516f180846a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 29 Oct 2011 12:51:53 -0400 Subject: Correctly NUL-terminate link name in sprof --- elf/sprof.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'elf') diff --git a/elf/sprof.c b/elf/sprof.c index dbe217b..069649a 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 -- cgit v1.1