diff options
Diffstat (limited to 'usr/src/lib/libproc/common/Pscantext.c')
-rw-r--r-- | usr/src/lib/libproc/common/Pscantext.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr/src/lib/libproc/common/Pscantext.c b/usr/src/lib/libproc/common/Pscantext.c index 72d85c06f6..08470bcd22 100644 --- a/usr/src/lib/libproc/common/Pscantext.c +++ b/usr/src/lib/libproc/common/Pscantext.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -33,6 +32,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include <limits.h> #include "libproc.h" #include "Pcontrol.h" @@ -47,7 +47,7 @@ int Pscantext(struct ps_prochandle *P) { - char mapfile[100]; + char mapfile[PATH_MAX]; int mapfd; off_t offset; /* offset in text section */ off_t endoff; /* ending offset in text section */ @@ -80,7 +80,8 @@ Pscantext(struct ps_prochandle *P) } /* open the /proc/<pid>/map file */ - (void) sprintf(mapfile, "/proc/%d/map", (int)P->pid); + (void) snprintf(mapfile, sizeof (mapfile), "%s/%d/map", + procfs_path, (int)P->pid); if ((mapfd = open(mapfile, O_RDONLY)) < 0) { dprintf("failed to open %s: %s\n", mapfile, strerror(errno)); return (-1); |