handle forbidden dir exclusions properly now

This commit is contained in:
Rudolf Polzer 2011-07-01 12:49:31 +02:00
parent 636baaba0f
commit db1787bbfa
2 changed files with 30 additions and 8 deletions

View File

@ -316,11 +316,18 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules)
for(j = 0; j < g_numForbiddenDirs; ++j) for(j = 0; j < g_numForbiddenDirs; ++j)
{ {
const char *p = strrchr(directory, '/'); char* dbuf = g_strdup(directory);
p = (p ? (p+1) : directory); if(*dbuf && dbuf[strlen(dbuf)-1] == '/')
dbuf[strlen(dbuf)-1] = 0;
const char *p = strrchr(dbuf, '/');
p = (p ? (p+1) : dbuf);
if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
{
g_free(dbuf);
break; break;
} }
g_free(dbuf);
}
if(j < g_numForbiddenDirs) if(j < g_numForbiddenDirs)
{ {
printf("Directory %s matched by forbidden dirs, removed\n", directory); printf("Directory %s matched by forbidden dirs, removed\n", directory);
@ -383,8 +390,12 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules)
break; break;
for(j = 0; j < g_numForbiddenDirs; ++j) for(j = 0; j < g_numForbiddenDirs; ++j)
if(!string_compare_nocase_upper(name, g_strForbiddenDirs[j])) {
const char *p = strrchr(name, '/');
p = (p ? (p+1) : name);
if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
break; break;
}
if(j < g_numForbiddenDirs) if(j < g_numForbiddenDirs)
continue; continue;

View File

@ -161,11 +161,18 @@ void vfsInitDirectory (const char *path)
for(j = 0; j < g_numForbiddenDirs; ++j) for(j = 0; j < g_numForbiddenDirs; ++j)
{ {
const char *p = strrchr(path, '/'); char* dbuf = g_strdup(path);
p = (p ? (p+1) : path); if(*dbuf && dbuf[strlen(dbuf)-1] == '/')
dbuf[strlen(dbuf)-1] = 0;
const char *p = strrchr(dbuf, '/');
p = (p ? (p+1) : dbuf);
if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
{
g_free(dbuf);
break; break;
} }
g_free(dbuf);
}
if(j < g_numForbiddenDirs) if(j < g_numForbiddenDirs)
return; return;
@ -193,8 +200,12 @@ void vfsInitDirectory (const char *path)
break; break;
for(j = 0; j < g_numForbiddenDirs; ++j) for(j = 0; j < g_numForbiddenDirs; ++j)
if(!Q_stricmp(name, g_strForbiddenDirs[j])) {
const char *p = strrchr(name, '/');
p = (p ? (p+1) : name);
if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
break; break;
}
if(j < g_numForbiddenDirs) if(j < g_numForbiddenDirs)
continue; continue;