summaryrefslogtreecommitdiff
path: root/lib/util/util.c
diff options
context:
space:
mode:
authorAurelien Aptel <aaptel@suse.com>2016-02-25 14:11:10 +0100
committerJeremy Allison <jra@samba.org>2016-03-01 02:25:22 +0100
commit2bd28d23fdac82f366c0e9d412d2fefca9c077eb (patch)
tree0c5b52c5c0d1cd6b8f19dd2ac8ba89ec6ba63d6f /lib/util/util.c
parent6d008556722a5bca73e5881345497ec8f97595dd (diff)
downloadsamba-2bd28d23fdac82f366c0e9d412d2fefca9c077eb.tar.gz
lib/util/util.c: move null-check before use
moves a null pointer check *before* the pointer is used in the strlen() call - still allocate the `fname` array on the stack - still compiles under C90 definition/code mixing rules Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <rb@sernet.de> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Mar 1 02:25:22 CET 2016 on sn-devel-144
Diffstat (limited to 'lib/util/util.c')
-rw-r--r--lib/util/util.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/util/util.c b/lib/util/util.c
index 03edd7f7761..683741c60f7 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -66,15 +66,11 @@ _PUBLIC_ const char *tmpdir(void)
**/
int create_unlink_tmp(const char *dir)
{
- size_t len = strlen(dir);
+ size_t len = strlen(dir ? dir : (dir = tmpdir()));
char fname[len+25];
int fd;
mode_t mask;
- if (!dir) {
- dir = tmpdir();
- }
-
len = snprintf(fname, sizeof(fname), "%s/listenerlock_XXXXXX", dir);
if (len >= sizeof(fname)) {
errno = ENOMEM;