diff options
author | Xabier Oneca <xoneca@gmail.com> | 2020-12-01 23:14:59 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-08 18:46:32 +0100 |
commit | abaee4aada7c91da6a43a83e9a73f98916a803a4 (patch) | |
tree | 29bec8376182d55165b245806b39e55a43dd1eca | |
parent | c9b93cf2908c845c60ad70cbed0074c4c0903208 (diff) | |
download | busybox-w32-abaee4aada7c91da6a43a83e9a73f98916a803a4.tar.gz busybox-w32-abaee4aada7c91da6a43a83e9a73f98916a803a4.tar.bz2 busybox-w32-abaee4aada7c91da6a43a83e9a73f98916a803a4.zip |
mkdtemp: proper error detection on mktemp
On error, mktemp returns an empty string, not NULL.
Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/platform.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/platform.c b/libbb/platform.c index 03bbb798b..d2b263a6d 100644 --- a/libbb/platform.c +++ b/libbb/platform.c | |||
@@ -107,7 +107,8 @@ void* FAST_FUNC memrchr(const void *s, int c, size_t n) | |||
107 | /* This is now actually part of POSIX.1, but was only added in 2008 */ | 107 | /* This is now actually part of POSIX.1, but was only added in 2008 */ |
108 | char* FAST_FUNC mkdtemp(char *template) | 108 | char* FAST_FUNC mkdtemp(char *template) |
109 | { | 109 | { |
110 | if (mktemp(template) == NULL || mkdir(template, 0700) != 0) | 110 | /* NB: on error, mktemp returns an empty string, not NULL */ |
111 | if (mktemp(template)[0] == '\0' || mkdir(template, 0700) != 0) | ||
111 | return NULL; | 112 | return NULL; |
112 | return template; | 113 | return template; |
113 | } | 114 | } |