[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.1 and 1.3

version 1.1, 2015/03/19 14:57:29 version 1.3, 2020/06/15 01:37:15
Line 1 
Line 1 
 #include "config.h"  /* $Id$ */
   
 #if HAVE_MKDTEMP  
   
 int dummy;  
   
 #else  
   
 /*      $Id$    */  
 /*  /*
  * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
  *   *
Line 25  int dummy;
Line 17  int dummy;
  * The algorithm of this function is inspired by OpenBSD mkdtemp(3)   * The algorithm of this function is inspired by OpenBSD mkdtemp(3)
  * by Theo de Raadt and Todd Miller, but the code differs.   * by Theo de Raadt and Todd Miller, but the code differs.
  */   */
   #include "config.h"
   
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <errno.h>  #include <errno.h>
Line 45  mkdtemp(char *path)
Line 38  mkdtemp(char *path)
         for (tries = INT_MAX; tries; tries--) {          for (tries = INT_MAX; tries; tries--) {
                 if (mktemp(path) == NULL) {                  if (mktemp(path) == NULL) {
                         errno = EEXIST;                          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)                  if (errno != EEXIST)
                         return(NULL);                          return NULL;
                 for (cp = start; *cp != '\0'; cp++)                  for (cp = start; *cp != '\0'; cp++)
                         *cp = 'X';                          *cp = 'X';
         }          }
         errno = EEXIST;          errno = EEXIST;
         return(NULL);          return NULL;
 }  }
   
 #endif  

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

CVSweb