stroke: Use thread-safe dirname(3)

This commit is contained in:
Tobias Brunner
2014-02-24 12:04:11 +01:00
parent 18019a3b89
commit 849e401b37
+4 -6
View File
@@ -17,7 +17,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <libgen.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
@@ -1130,7 +1129,7 @@ static void load_secrets(private_stroke_cred_t *this, mem_cred_t *secrets,
}
if (line.len > strlen("include ") && strpfx(line.ptr, "include "))
{
char **expanded, *path, *dir, pattern[PATH_MAX];
char **expanded, *dir, pattern[PATH_MAX];
u_char *pos;
if (level > MAX_SECRETS_RECURSION)
@@ -1158,18 +1157,17 @@ static void load_secrets(private_stroke_cred_t *this, mem_cred_t *secrets,
}
else
{ /* use directory of current file if relative */
path = strdup(file);
dir = dirname(path);
dir = path_dirname(file);
if (line.len + 1 + strlen(dir) + 1 > sizeof(pattern))
{
DBG1(DBG_CFG, "include pattern too long, ignored");
free(path);
free(dir);
continue;
}
snprintf(pattern, sizeof(pattern), "%s/%.*s",
dir, (int)line.len, line.ptr);
free(path);
free(dir);
}
#ifdef HAVE_GLOB_H
{