From: Tobias Brunner Date: Fri, 21 Feb 2014 17:49:16 +0000 (+0100) Subject: stroke: Use thread-safe dirname(3) X-Git-Tag: 5.1.2~9^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=849e401b37db6d1b83b795f5418f3f25027b3ca0;p=thirdparty%2Fstrongswan.git stroke: Use thread-safe dirname(3) --- diff --git a/src/libcharon/plugins/stroke/stroke_cred.c b/src/libcharon/plugins/stroke/stroke_cred.c index a73c940b19..f908219ed2 100644 --- a/src/libcharon/plugins/stroke/stroke_cred.c +++ b/src/libcharon/plugins/stroke/stroke_cred.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -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 {