Changeset 3012


Ignore:
Timestamp:
Apr 7, 2007, 6:29:36 AM (18 years ago)
Author:
bird
Message:

Fixed tempnam(NULL,NULL) crash and errno clobbering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/io/_tempnam.c

    r1454 r3012  
    1111#include <io.h>
    1212#include <errno.h>
     13#include <sys/stat.h>
    1314#include <sys/param.h>
    1415#include <emx/io.h>
    15 #include <emx/syscalls.h>
    1616#include "_tmp.h"
    1717
     
    2222static int _isdir (char *dst, const char *src)
    2323{
    24   int attr;
     24  struct stat s;
    2525
    2626  if (_fullpath (dst, src, MAXPATHLEN) != 0)
    2727    return 0;
    28   attr = __chmod (dst, 0, 0);
    29   return attr >= 0 && (attr & _A_SUBDIR);
     28  return lstat (dst, &s) == 0
     29      && S_ISDIR(s.st_mode);
    3030}
    3131
     
    5959    tmpname[len++] = '/';
    6060  p = tmpname + len;
     61
     62  if (!prefix)
     63    prefix = "kLC";
    6164
    6265  TMPIDX_LOCK;
     
    98101  free (tmpname);
    99102  p = strdup (buf);
    100   if (p == NULL)
     103  if (p != NULL)
     104    errno = saved_errno;
     105  else
    101106    errno = ENOMEM;
    102107  return p;
Note: See TracChangeset for help on using the changeset viewer.