On error, mktemp returns an empty string, not NULL.
Signed-off-by: Xabier Oneca <[email protected]>
---
libbb/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libbb/platform.c b/libbb/platform.c
index 03bbb798..187670a8 100644
--- a/libbb/platform.c
+++ b/libbb/platform.c
@@ -107,7 +107,7 @@ void* FAST_FUNC memrchr(const void *s, int c, size_t n)
/* This is now actually part of POSIX.1, but was only added in 2008 */
char* FAST_FUNC mkdtemp(char *template)
{
- if (mktemp(template) == NULL || mkdir(template, 0700) != 0)
+ if (mktemp(template)[0] == '\0' || mkdir(template, 0700) != 0)
return NULL;
return template;
}
--
2.28.0
From 07f87296aef5db6c3098e36e1d72f0b73509df7c Mon Sep 17 00:00:00 2001
From: Xabier Oneca <[email protected]>
Date: Tue, 1 Dec 2020 23:14:59 +0100
Subject: [PATCH] mkdtemp: proper error detection on mktemp
On error, mktemp returns an empty string, not NULL.
Signed-off-by: Xabier Oneca <[email protected]>
---
libbb/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libbb/platform.c b/libbb/platform.c
index 03bbb798..187670a8 100644
--- a/libbb/platform.c
+++ b/libbb/platform.c
@@ -107,7 +107,7 @@ void* FAST_FUNC memrchr(const void *s, int c, size_t n)
/* This is now actually part of POSIX.1, but was only added in 2008 */
char* FAST_FUNC mkdtemp(char *template)
{
- if (mktemp(template) == NULL || mkdir(template, 0700) != 0)
+ if (mktemp(template)[0] == '\0' || mkdir(template, 0700) != 0)
return NULL;
return template;
}
--
2.28.0
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox