Ignore:
Timestamp:
Jun 17, 2007, 2:11:18 AM (18 years ago)
Author:
bird
Message:

do _realrealpath on the TMPDIR before using it. Fixes #179.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/emx/src/emxomf/emxomfld.c

    r3417 r3462  
    634634    char            szLooklike[32];
    635635    pid_t           pid = getpid();
    636     const char *    pszTmp = getenv("TMP");
    637     if (!pszTmp)    pszTmp = getenv("TMPDIR");
    638     if (!pszTmp)    pszTmp = getenv("TEMP");
    639     if (!pszTmp)    pszTmp = ".";
     636    static char     s_szTmp[_MAX_PATH + 1];
     637
     638    /* We need to apply _realrealpath to the tmpdir, so resolve that once and for all. */
     639    if (!s_szTmp[0])
     640    {
     641        const char *    pszTmp = getenv("TMP");
     642        if (!pszTmp)    pszTmp = getenv("TMPDIR");
     643        if (!pszTmp)    pszTmp = getenv("TEMP");
     644        if (!pszTmp)    pszTmp = ".";
     645        if (!_realrealpath(pszTmp, s_szTmp, sizeof(s_szTmp)))
     646        {
     647            printf("emxomfld: _realrealpath failed on '%s'!!!\n", pszTmp);
     648            exit(1);
     649        }
     650    }
     651
    640652    if (pszLooklike)
    641653    {
     
    664676            return -1;
    665677        gettimeofday(&tv, NULL);
    666         sprintf(pszFile, "%s\\%s%s%x%lx%d%lx%s", pszTmp, pszPrefix, pszLooklike, pid, tv.tv_sec, c, tv.tv_usec, pszSuffix);
     678        sprintf(pszFile, "%s\\%s%s%x%lx%d%lx%s", s_szTmp, pszPrefix, pszLooklike, pid, tv.tv_sec, c, tv.tv_usec, pszSuffix);
    667679    } while (!stat(pszFile, &s));
    668680
Note: See TracChangeset for help on using the changeset viewer.