[BACK]Return to compat_mkdtemp.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/compat_mkdtemp.c between version 1.3 and 1.4

version 1.3, 2020/06/15 01:37:15 version 1.4, 2021/09/19 15:02:55
Line 1 
Line 1 
 /* $Id$ */  /* $Id$ */
 /*  /*
  * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2015, 2021 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 36  mkdtemp(char *path)
Line 36  mkdtemp(char *path)
                 start--;                  start--;
   
         for (tries = INT_MAX; tries; tries--) {          for (tries = INT_MAX; tries; tries--) {
                 if (mktemp(path) == NULL) {                  if (mktemp(path) == NULL)
                         errno = EEXIST;  
                         return NULL;                          return NULL;
                 }  
                 if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0)                  if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0)
                         return path;                          return path;
                 if (errno != EEXIST)  
                         return NULL;  
                 for (cp = start; *cp != '\0'; cp++)                  for (cp = start; *cp != '\0'; cp++)
                         *cp = 'X';                          *cp = 'X';
                   if (errno != EEXIST)
                           return NULL;
         }          }
         errno = EEXIST;          errno = EEXIST;
         return NULL;          return NULL;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

CVSweb