settings: Use thread-safe dirname(3)

This commit is contained in:
Tobias Brunner
2014-02-24 12:04:11 +01:00
parent 766141bc77
commit 18019a3b89
+3 -5
View File
@@ -20,7 +20,6 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <libgen.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@@ -1302,15 +1301,14 @@ static bool parse_files(linked_list_t *contents, char *file, int level,
} }
else else
{ /* base relative paths to the directory of the current file */ { /* base relative paths to the directory of the current file */
char *path = strdup(file); char *dir = path_dirname(file);
char *dir = dirname(path);
if (snprintf(pat, sizeof(pat), "%s/%s", dir, pattern) >= sizeof(pat)) if (snprintf(pat, sizeof(pat), "%s/%s", dir, pattern) >= sizeof(pat))
{ {
DBG1(DBG_LIB, "include pattern too long, ignored"); DBG1(DBG_LIB, "include pattern too long, ignored");
free(path); free(dir);
return TRUE; return TRUE;
} }
free(path); free(dir);
} }
#ifdef HAVE_GLOB_H #ifdef HAVE_GLOB_H
{ {