Ticket #300: spawnvpe.diff

File spawnvpe.diff, 944 bytes (added by dmik, 10 years ago)
  • spawnvpe.c

    old new  
    1616    char    path[PATH_MAX];
    1717    int     rc;
    1818
    19     if (strlen(name) >= sizeof(exe) - 4)
     19    if (_path(path, name))
    2020    {
    21         errno = ENAMETOOLONG;
    22         LIBCLOG_ERROR_RETURN(-1, "ret -1 - name is too long, %d bytes: %s\n", strlen(name), name);
     21        if (strlen(name) >= sizeof(exe) - 4)
     22        {
     23            errno = ENAMETOOLONG;
     24            LIBCLOG_ERROR_RETURN(-1, "ret -1 - name is too long, %d bytes: %s\n", strlen(name), name);
     25        }
     26        strcpy(exe, name);
     27        _defext(exe, "exe");
     28        if (_path(path, exe))
     29            LIBCLOG_ERROR_RETURN_INT(-1);
    2330    }
    24     strcpy(exe, name);
    25     _defext(exe, "exe");
    26     if (_path(path, exe))
    27         LIBCLOG_ERROR_RETURN_INT(-1);
    2831    rc = spawnve(mode, path, argv, envp);
    2932    LIBCLOG_RETURN_INT(rc);
    3033}