1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

- fixed possible crash bug because a variable allocated on stack was

returned by a function
- removed obsolete macro
This commit is contained in:
dan
2004-11-11 14:14:52 +00:00
parent 9f89695c48
commit 684621ecd4
2 changed files with 8 additions and 5 deletions

View File

@@ -1215,10 +1215,12 @@ StrConcatDot(char *a, char *b)
} }
#define MAX_CMD_SIZE 4096
Bool Bool
GetCommandForPid(int pid, char ***argv, int *argc) GetCommandForPid(int pid, char ***argv, int *argc)
{ {
char buf[1024]; static char buf[MAX_CMD_SIZE];
FILE *fPtr; FILE *fPtr;
int count, i, j; int count, i, j;
Bool ok= False; Bool ok= False;
@@ -1226,9 +1228,9 @@ GetCommandForPid(int pid, char ***argv, int *argc)
sprintf(buf, "/proc/%d/cmdline", pid); sprintf(buf, "/proc/%d/cmdline", pid);
fPtr = fopen(buf, "r"); fPtr = fopen(buf, "r");
if (fPtr) { if (fPtr) {
count = read(fileno(fPtr), buf, 1024); count = read(fileno(fPtr), buf, MAX_CMD_SIZE);
if (count > 0) { if (count > 0) {
buf[count] = 0; buf[count-1] = 0;
for (i=0, *argc=0; i<count; i++) { for (i=0, *argc=0; i<count; i++) {
if (buf[i] == 0) { if (buf[i] == 0) {
(*argc)++; (*argc)++;
@@ -1246,6 +1248,9 @@ GetCommandForPid(int pid, char ***argv, int *argc)
if (i < count-1) { if (i < count-1) {
(*argv)[j++] = &buf[i+1]; (*argv)[j++] = &buf[i+1];
} }
if (j == *argc) {
break;
}
} }
ok= True; ok= True;
} }

View File

@@ -515,8 +515,6 @@
#define MAX_RESTART_ARGS 16 #define MAX_RESTART_ARGS 16
#define MAX_COMMAND_SIZE 1024
#define MAX_DEAD_PROCESSES 128 #define MAX_DEAD_PROCESSES 128