diff options
Diffstat (limited to 'usr/src/lib/libproc/common/Pzone.c')
-rw-r--r-- | usr/src/lib/libproc/common/Pzone.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr/src/lib/libproc/common/Pzone.c b/usr/src/lib/libproc/common/Pzone.c index 3c4999bbe4..d2562a2a79 100644 --- a/usr/src/lib/libproc/common/Pzone.c +++ b/usr/src/lib/libproc/common/Pzone.c @@ -795,9 +795,14 @@ Pfindmap(struct ps_prochandle *P, map_info_t *mptr, char *s, size_t n) /* Try /proc first to get the real object name */ if ((Pstate(P) != PS_DEAD) && (mptr->map_pmap.pr_mapname[0] != '\0')) { - (void) snprintf(buf, sizeof (buf), "%s/%d/path/%s", + char path[PATH_MAX]; + + len = snprintf(path, sizeof (path), "%s/%d/path/%s", procfs_path, (int)P->pid, mptr->map_pmap.pr_mapname); - if ((len = readlink(buf, buf, sizeof (buf))) > 0) { + if (len < 0 || (size_t)len >= sizeof (path)) + return (NULL); + + if ((len = readlink(path, buf, sizeof (buf))) > 0) { buf[len] = '\0'; (void) Plofspath(buf, buf, sizeof (buf)); (void) strlcpy(s, buf, n); |