Fix off-by-one when reading link name in sprof
authorAndreas Schwab <schwab@redhat.com>
Fri, 4 Nov 2011 09:21:15 +0000 (10:21 +0100)
committerAndreas Schwab <schwab@redhat.com>
Fri, 4 Nov 2011 09:25:00 +0000 (10:25 +0100)
ChangeLog
elf/sprof.c

index a65182a..6622603 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-11-04  Andreas Schwab  <schwab@redhat.com>
+
+       * elf/sprof.c (load_shobj): Fix off-by-one when reading link name.
+
 2011-11-03  Andreas Schwab  <schwab@redhat.com>
 
        * nscd/nscd.c (main): Don't start AVC thread until credentials are
index 6182599..c90c22c 100644 (file)
@@ -597,7 +597,7 @@ load_shobj (const char *name)
       char origprocname[sizeof (procpath) + sizeof (int) * 3];
       snprintf (origprocname, sizeof (origprocname), procpath, fd);
       char *origlink = (char *) alloca (PATH_MAX);
-      ssize_t n = readlink (origprocname, origlink, PATH_MAX);
+      ssize_t n = readlink (origprocname, origlink, PATH_MAX - 1);
       if (n == -1)
        goto no_debuginfo;
       origlink[n] = '\0';