From 684621ecd499fe859d7675ef796af3d6df95bd78 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Nov 2004 14:14:52 +0000 Subject: [PATCH] - fixed possible crash bug because a variable allocated on stack was returned by a function - removed obsolete macro --- src/misc.c | 11 ++++++++--- src/wconfig.h.in | 2 -- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/misc.c b/src/misc.c index 11a68709..46bebf8c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1215,10 +1215,12 @@ StrConcatDot(char *a, char *b) } +#define MAX_CMD_SIZE 4096 + Bool GetCommandForPid(int pid, char ***argv, int *argc) { - char buf[1024]; + static char buf[MAX_CMD_SIZE]; FILE *fPtr; int count, i, j; Bool ok= False; @@ -1226,9 +1228,9 @@ GetCommandForPid(int pid, char ***argv, int *argc) sprintf(buf, "/proc/%d/cmdline", pid); fPtr = fopen(buf, "r"); if (fPtr) { - count = read(fileno(fPtr), buf, 1024); + count = read(fileno(fPtr), buf, MAX_CMD_SIZE); if (count > 0) { - buf[count] = 0; + buf[count-1] = 0; for (i=0, *argc=0; i