Changeset 4231

Show
Ignore:
Timestamp:
07/30/08 01:36:58 (6 years ago)
Author:
douglask
Message:

32bit Debian Etch's glibc has an issue with malloc being inside a fork/exec.

As some glibc version had issues if malloc/free was outside a fork/exec,
now avoid using malloc altogther by using a char *args[64] local variable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • rat/trunk/process.c

    r4226 r4231  
    9494                debug_msg("Running as root? PATH unmodified\n"); 
    9595        } 
     96        /* some glibc versions have issues with malloc/free when used inside or 
     97           in some cases outside a fork/exec, so we now use a args[64] array instead of 
     98           xmalloc'ing it. In the unlikely event the array needs to hold more 
     99           command-line arguments, print a error message */ 
     100        if ((2 * num_tokens) + argc + 4 >= 64) { 
     101                fprintf(stderr, "Exceeded max of %i command-line arguments\n", 
     102                        64 - (2 * num_tokens) + 4); 
     103                exit(1); 
     104        } 
    96105        /* Fork off the sub-process... */ 
    97106        *pid = fork(); 
     
    100109                abort(); 
    101110        } else if (*pid == 0) { 
    102                 char **args = xmalloc((2 * num_tokens) + argc + 4); 
     111                char *args[64]; 
    103112                int numargs=0; 
    104113 
     
    115124                args[numargs++] = NULL; 
    116125                execvp( proc_name, args ); 
    117          
     126 
    118127                perror("Cannot execute subprocess"); 
    119                 xfree(args); 
    120                 /* Note: this MUST NOT be exit() or abort(), since they affect the standard */ 
    121                 /* IO channels in the parent process (fork duplicates file descriptors, but */ 
     128                /* Note: this MUST NOT be exit() or abort(), since they affect the standard */ 
     129                /* IO channels in the parent process (fork duplicates file descriptors, but */ 
    122130                /* they still point to the same underlying file).                           */ 
    123131                _exit(1);