aboutsummaryrefslogtreecommitdiff
path: root/elf/sprof.c
diff options
context:
space:
mode:
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