[BusyBox] Bug in pidof !

Steven Scholz steven.scholz at imc-berlin.de
Sun Nov 24 07:46:03 UTC 2002


I wrote:
> 
> Hi there,
> 
> I think there is a bug in the pidof applet in busybox-unstable-20021123
> resulting in "Segmentation fault" when using pidof without "-s".

Shell we do something like:

diff -p -u -r1.1.1.1 pidof.c
--- procps/pidof.c      22 Oct 2002 12:21:13 -0000      1.1.1.1
+++ procps/pidof.c      24 Nov 2002 14:43:01 -0000
@@ -52,16 +52,16 @@ extern int pidof_main(int argc, char **a
 
        /* Looks like everything is set to go. */
        while(optind < argc) {
-               long* pidList;
+               long* pidList, tmp;
 
                pidList = find_pid_by_name(argv[optind]);
-               for(; *pidList > 0; pidList++) {
+               for(tmp=pidList; *pidList > 0; pidList++) {
                        printf("%s%ld", (n++ ? " " : ""), (long)*pidList);
                        fail = 0;
                        if (single_flag)
                                break;
                }
-               free(pidList);
+               free(tmp);
                optind++;
 
        }

????

Steven



More information about the busybox mailing list