stroke: Use thread-safe dirname(3)
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <libgen.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.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 "))
|
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;
|
u_char *pos;
|
||||||
|
|
||||||
if (level > MAX_SECRETS_RECURSION)
|
if (level > MAX_SECRETS_RECURSION)
|
||||||
@@ -1158,18 +1157,17 @@ static void load_secrets(private_stroke_cred_t *this, mem_cred_t *secrets,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* use directory of current file if relative */
|
{ /* use directory of current file if relative */
|
||||||
path = strdup(file);
|
dir = path_dirname(file);
|
||||||
dir = dirname(path);
|
|
||||||
|
|
||||||
if (line.len + 1 + strlen(dir) + 1 > sizeof(pattern))
|
if (line.len + 1 + strlen(dir) + 1 > sizeof(pattern))
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "include pattern too long, ignored");
|
DBG1(DBG_CFG, "include pattern too long, ignored");
|
||||||
free(path);
|
free(dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(pattern, sizeof(pattern), "%s/%.*s",
|
snprintf(pattern, sizeof(pattern), "%s/%.*s",
|
||||||
dir, (int)line.len, line.ptr);
|
dir, (int)line.len, line.ptr);
|
||||||
free(path);
|
free(dir);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_GLOB_H
|
#ifdef HAVE_GLOB_H
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user