Ticket #356: _response.diff

File _response.diff, 1.3 KB (added by KO Myung-Hun, 9 years ago)

patch for _response()

  • src/emx/src/lib/misc/response.c

    diff --git a/src/emx/src/lib/misc/response.c b/src/emx/src/lib/misc/response.c
    index 669b7ad..b5a9744 100755
    a b void _response (int *argcp, char ***argvp)  
    2323{
    2424  int i, old_argc, new_argc, new_alloc;
    2525  char **old_argv, **new_argv;
    26   char line[1+8192], *p;
     26  char *line, *p;
    2727  FILE *f;
    2828
    2929  old_argc = *argcp; old_argv = *argvp;
    void _response (int *argcp, char ***argvp)  
    4444        RPUT (old_argv[i]);
    4545      else
    4646        {
     47          long filesize;
     48
     49          fseek(f, 0, SEEK_END);
     50          filesize = ftell(f);
     51          fseek(f, 0, SEEK_SET);
     52          line = malloc(filesize+1+1); /* 1 for type, 1 for NUL */
     53          if (!line)
     54            goto out_of_memory;
    4755          line[0] = __KLIBC_ARG_NONZERO | __KLIBC_ARG_RESPONSE;
    48           while (fgets (line+1, sizeof (line)-1, f) != NULL)
     56          while (fgets (line+1, filesize+1, f) != NULL)
    4957            {
    5058              p = strchr (line+1, '\n');
    5159              if (p != NULL) *p = 0;
    void _response (int *argcp, char ***argvp)  
    5462                goto out_of_memory;
    5563              RPUT (p+1);
    5664            }
     65          free (line);
    5766          if (ferror (f))
    5867            {
    5968              fputs ("Cannot read response file\n", stderr);