diff options
| author | Eric Andersen <andersen@codepoet.org> | 2003-08-06 08:22:10 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2003-08-06 08:22:10 +0000 |
| commit | 5378fbcb3358e9ea06d53453e5d677b96a9d9228 (patch) | |
| tree | eb8e96c20fc7288c9711af1874cba6d1ccfeb9c8 | |
| parent | 8f4ef159f09e1b5d09f7f7d2fcbf9e4a78c375c7 (diff) | |
| download | busybox-w32-5378fbcb3358e9ea06d53453e5d677b96a9d9228.tar.gz busybox-w32-5378fbcb3358e9ea06d53453e5d677b96a9d9228.tar.bz2 busybox-w32-5378fbcb3358e9ea06d53453e5d677b96a9d9228.zip | |
Joe.C writes:
I've reported this bug in April and it still
exists in 1.00-pre2. So I made patches for
both 0.60.x and 1.00-pre2. The patch is very
simple, just use strncmp instead of strcmp.
Please apply if it is OK.
Here's the procedure to test this problem:
Create a executable with very long name, say
'test_1234567890123456' and execute it. Try
using 'killall' or 'pidof' to find/kill this
program. Without this patch, you can't find
the program.
| -rw-r--r-- | libbb/find_pid_by_name.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index b857c0bc7..77fa0179e 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
| @@ -25,6 +25,10 @@ | |||
| 25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
| 26 | #include "libbb.h" | 26 | #include "libbb.h" |
| 27 | 27 | ||
| 28 | #define COMM_LEN 16 /* synchronize with size of comm in struct task_struct | ||
| 29 | in /usr/include/linux/sched.h */ | ||
| 30 | |||
| 31 | |||
| 28 | /* find_pid_by_name() | 32 | /* find_pid_by_name() |
| 29 | * | 33 | * |
| 30 | * Modified by Vladimir Oleynik for use with libbb/procps.c | 34 | * Modified by Vladimir Oleynik for use with libbb/procps.c |
| @@ -46,7 +50,7 @@ extern long* find_pid_by_name( const char* pidName) | |||
| 46 | #else | 50 | #else |
| 47 | while ((p = procps_scan(0)) != 0) { | 51 | while ((p = procps_scan(0)) != 0) { |
| 48 | #endif | 52 | #endif |
| 49 | if (strcmp(p->short_cmd, pidName) == 0) { | 53 | if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) { |
| 50 | pidList=xrealloc( pidList, sizeof(long) * (i+2)); | 54 | pidList=xrealloc( pidList, sizeof(long) * (i+2)); |
| 51 | pidList[i++]=p->pid; | 55 | pidList[i++]=p->pid; |
| 52 | } | 56 | } |
