← Commit list

abaee4aad

Xabier Oneca
Xabier Oneca
2020-12-08
SUCCESS Duration: 150s

Subject

mkdtemp: proper error detection on mktemp

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/platform.c+2 -1
@@ -107,7 +107,8 @@ 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)
+ /* NB: on error, mktemp returns an empty string, not NULL */
+ if (mktemp(template)[0] == '\0' || mkdir(template, 0700) != 0)
return NULL;
return template;
}