From: Enrico Scholz Date: Thu, 18 Mar 2004 05:28:14 +0000 (+0000) Subject: filter out relative and absolute paths; when they are not pointing to X-Git-Tag: VERSION_0_10~284 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b73136f9960c2b4b58f5064c3fd1d88fbd23f9ec;p=util-vserver.git 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 --- 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;