ARG_MAX on Solaris is *very* large, 2 MB. Allocating that much on the
authorhume-github <hume-ml+github@bofh.ca>
Thu, 27 Sep 2012 13:43:09 +0000 (10:43 -0300)
committerFlorian Forster <octo@collectd.org>
Tue, 2 Oct 2012 07:32:47 +0000 (09:32 +0200)
stack (local variable) overflows the thread stack and crashes the
process in weird and interesting ways.

"int i" is a useless variable and breaks the build with -Werror.

Signed-off-by: Florian Forster <octo@collectd.org>
src/processes.c

index dcdaaf2..c77859d 100644 (file)
@@ -1230,10 +1230,8 @@ static int ps_read_process(int pid, procstat_t *ps, char *state)
 {
        char filename[64];
        char f_psinfo[64], f_usage[64];
-       int i;
        char *buffer;
 
-
        pstatus_t *myStatus;
        psinfo_t *myInfo;
        prusage_t *myUsage;
@@ -2080,7 +2078,7 @@ static int ps_read (void)
        procstat_t *ps_ptr;
        char state;
 
-       char cmdline[ARG_MAX];
+       char cmdline[PRARGSZ];
 
        ps_list_reset ();