From: Eric Andersen Date: Wed, 6 Aug 2003 08:22:10 +0000 (-0000) Subject: Joe.C writes: X-Git-Tag: 1_00_pre3~97 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5378fbcb3358e9ea06d53453e5d677b96a9d9228;p=oweals%2Fbusybox.git 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. --- 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 @@ #include #include "libbb.h" +#define COMM_LEN 16 /* synchronize with size of comm in struct task_struct + in /usr/include/linux/sched.h */ + + /* find_pid_by_name() * * Modified by Vladimir Oleynik for use with libbb/procps.c @@ -46,7 +50,7 @@ extern long* find_pid_by_name( const char* pidName) #else while ((p = procps_scan(0)) != 0) { #endif - if (strcmp(p->short_cmd, pidName) == 0) { + if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) { pidList=xrealloc( pidList, sizeof(long) * (i+2)); pidList[i++]=p->pid; }