Print this page
OS-3280 need a way to specify the root of a native system in the lx brand
OS-3279 lx brand should allow delegated datasets
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

@@ -39,10 +39,12 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <signal.h>
 #include <libproc.h>
+#include <limits.h>
+#include "ptools_common.h"
 
 static  int     look(pid_t);
 static  void    hr_min_sec(char *, long);
 static  void    prtime(char *, timestruc_t *);
 static  int     perr(const char *);

@@ -187,11 +189,11 @@
 }
 
 static int
 look(pid_t pid)
 {
-        char pathname[100];
+        char pathname[PATH_MAX];
         int rval = 0;
         int fd;
         psinfo_t psinfo;
         prusage_t prusage;
         timestruc_t real, user, sys;

@@ -201,11 +203,12 @@
         pfirst++;
 
         if (proc_get_psinfo(pid, &psinfo) < 0)
                 return (perr("read psinfo"));
 
-        (void) sprintf(pathname, "/proc/%d/usage", (int)pid);
+        (void) proc_snprintf(pathname, sizeof (pathname), "/proc/%d/usage",
+            (int)pid);
         if ((fd = open(pathname, O_RDONLY)) < 0)
                 return (perr("open usage"));
 
         if (read(fd, &prusage, sizeof (prusage)) != sizeof (prusage))
                 rval = perr("read usage");