diff options
-rw-r--r-- | compat_mkdtemp.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/compat_mkdtemp.c b/compat_mkdtemp.c index fb67adfe..5e4c280a 100644 --- a/compat_mkdtemp.c +++ b/compat_mkdtemp.c @@ -1,6 +1,6 @@ /* $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 * purpose with or without fee is hereby granted, provided that the above @@ -36,16 +36,14 @@ mkdtemp(char *path) start--; for (tries = INT_MAX; tries; tries--) { - if (mktemp(path) == NULL) { - errno = EEXIST; + if (mktemp(path) == NULL) return NULL; - } if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) return path; - if (errno != EEXIST) - return NULL; for (cp = start; *cp != '\0'; cp++) *cp = 'X'; + if (errno != EEXIST) + return NULL; } errno = EEXIST; return NULL; |