Changeset 3462 for branches


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.

Location:
branches/libc-0.6/src/emx/src/emxomf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/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
  • branches/libc-0.6/src/emx/src/emxomf/weakld.c

    r2815 r3462  
    36113611    unsigned        c = 0;
    36123612    pid_t           pid = getpid();
    3613     const char *    pszTmp = getenv("TMP");
    3614     if (!pszTmp)    pszTmp = getenv("TMPDIR");
    3615     if (!pszTmp)    pszTmp = getenv("TEMP");
    3616     if (!pszTmp)    pszTmp = ".";
     3613    static char     s_szTmp[_MAX_PATH + 1];
     3614   
     3615    /* We need to apply _realrealpath to the tmpdir, so resolve that once and for all. */
     3616    if (!s_szTmp[0])
     3617    {
     3618        const char *    pszTmp = getenv("TMP");
     3619        if (!pszTmp)    pszTmp = getenv("TMPDIR");
     3620        if (!pszTmp)    pszTmp = getenv("TEMP");
     3621        if (!pszTmp)    pszTmp = ".";
     3622        if (!_realrealpath(pszTmp, s_szTmp, sizeof(s_szTmp)))
     3623        {
     3624            printf("emxomfld: _realrealpath failed on '%s'!!!\n", pszTmp);
     3625            exit(1);
     3626        }
     3627    }
    36173628
    36183629    do
     
    36223633            return -1;
    36233634        gettimeofday(&tv, NULL);
    3624         sprintf(pszFile, "%s\\%s%x%lx%d%lx%s", pszTmp, pszPrefix, pid, tv.tv_sec, c, tv.tv_usec, pszSuffix);
     3635        sprintf(pszFile, "%s\\%s%x%lx%d%lx%s", s_szTmp, pszPrefix, pid, tv.tv_sec, c, tv.tv_usec, pszSuffix);
    36253636    } while (!stat(pszFile, &s));
    36263637
Note: See TracChangeset for help on using the changeset viewer.