From b73136f9960c2b4b58f5064c3fd1d88fbd23f9ec Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Thu, 18 Mar 2004 05:28:14 +0000 Subject: [PATCH] filter out relative and absolute paths; when they are not pointing to an existing directory, the function fails git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1290 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/lib/getvservercfgstyle.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/util-vserver/lib/getvservercfgstyle.c b/util-vserver/lib/getvservercfgstyle.c index cc56433..ed99a45 100644 --- a/util-vserver/lib/getvservercfgstyle.c +++ b/util-vserver/lib/getvservercfgstyle.c @@ -28,6 +28,18 @@ #include #include +static inline bool +isRelPath(char const *p) +{ + return p[0]=='.' && (p[1]=='/' || (p[1]=='.' && p[2]=='/')); +} + +static inline bool +isAbsPath(char const *p) +{ + return p[0]=='/'; +} + vcCfgStyle vc_getVserverCfgStyle(char const *id) { @@ -41,9 +53,9 @@ vc_getVserverCfgStyle(char const *id) strcpy(buf, id); marker = buf+l1; strcpy(marker, "/vdir"); - + if (access(buf, X_OK)==0) res = vcCFG_RECENT_FULL; - else { + else if (!isRelPath(buf) && !isAbsPath(buf)) { strcpy(buf, CONFDIR "/"); strcpy(buf+sizeof(CONFDIR "/") - 1, id); marker = buf+sizeof(CONFDIR "/")+l1 - 1; -- 1.8.1.5