summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorSven Linker <sven.linker@kernkonzept.com>2024-02-07 10:27:58 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2024-02-18 05:56:22 +0100
commit41159c5cfd3538542107f928aa13ceeb3c98e62d (patch)
treea1c9ae3f484a5259ea971eb3023202dd0bb8a425 /libc/misc
parented6a9513157f54894629d8dfa8890df0245505ec (diff)
Avoid fall-through if file matching temporary name exists
During checking whether a temporary name can be created, it may happen that a file with this name already exists. Avoid falling through to opening the file name in this case, and return with an error instead. Signed-off-by: Sven Linker <sven.linker@kernkonzept.com>
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/internals/tempname.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c
index d3a8ccbd8..f9b714a68 100644
--- a/libc/misc/internals/tempname.c
+++ b/libc/misc/internals/tempname.c
@@ -218,7 +218,8 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind, int flags,
/* Give up now. */
return -1;
} else
- fd = 0;
+ /* File already exists, so return with non-zero value */
+ return -1;
}
case __GT_FILE:
fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);