[BusyBox-cvs] busybox/libbb find_pid_by_name.c,1.12,1.13
Erik Andersen
andersen at busybox.net
Wed Aug 6 08:21:55 UTC 2003
Update of /var/cvs/busybox/libbb
In directory winder:/tmp/cvs-serv17477/libbb
Modified Files:
find_pid_by_name.c
Log Message:
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.
Index: find_pid_by_name.c
===================================================================
RCS file: /var/cvs/busybox/libbb/find_pid_by_name.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- find_pid_by_name.c 14 Jul 2003 21:20:55 -0000 1.12
+++ find_pid_by_name.c 6 Aug 2003 08:21:52 -0000 1.13
@@ -25,6 +25,10 @@
#include <stdlib.h>
#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 @@
#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;
}
More information about the busybox-cvs
mailing list