aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-03-07 12:28:07 +0100
committerMartin Willi <martin@revosec.ch>2014-06-04 15:53:10 +0200
commit0b786610429a75e054a55408f862a349e5778d06 (patch)
tree6a00685ace0c3d8207ddd4c3c442fe1ae39db2d9 /src
parent0731d41ca9eefbf081a883aeacdf97533455234b (diff)
downloadstrongswan-0b786610429a75e054a55408f862a349e5778d06.tar.bz2
strongswan-0b786610429a75e054a55408f862a349e5778d06.tar.xz
libpts: Respect path separators when concatenating database filenames
As we can't use the system native directory separator on cross-platform measurements, we determine the path separator from the base directory format.
Diffstat (limited to 'src')
-rw-r--r--src/libpts/pts/pts_database.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/libpts/pts/pts_database.c b/src/libpts/pts/pts_database.c
index e9a0e5faa..f2e2c9c74 100644
--- a/src/libpts/pts/pts_database.c
+++ b/src/libpts/pts/pts_database.c
@@ -48,7 +48,7 @@ METHOD(pts_database_t, get_pathname, char*,
private_pts_database_t *this, bool is_dir, int id)
{
enumerator_t *e;
- char *path, *name, *pathname;
+ char *path, *name, *sep, *pathname = NULL;
if (is_dir)
{
@@ -70,11 +70,21 @@ METHOD(pts_database_t, get_pathname, char*,
"SELECT d.path, f.name FROM files AS f "
"JOIN directories AS d ON d.id = f.dir WHERE f.id = ?",
DB_INT, id, DB_TEXT, DB_TEXT);
- if (!e || !e->enumerate(e, &path, &name) ||
- asprintf(&pathname, "%s%s%s",
- path, streq(path, "/") ? "" : "/", name) == -1)
+ if (e && e->enumerate(e, &path, &name))
{
- pathname = NULL;
+ if (path[0] == '/')
+ { /* Unix style absolute path */
+ sep = "/";
+ }
+ else
+ { /* Windows absolute path */
+ sep = "\\";
+ }
+ if (asprintf(&pathname, "%s%s%s",
+ path, streq(path, "/") ? "" : sep, name) == -1)
+ {
+ pathname = NULL;
+ }
}
}
DESTROY_IF(e);
@@ -420,4 +430,3 @@ pts_database_t *pts_database_create(imv_database_t *imv_db)
return &this->public;
}
-