diff options
-rw-r--r-- | src/configreader.cpp | 15 | ||||
-rw-r--r-- | src/modules.cpp | 7 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 64641805c..9e13dfae1 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1428,12 +1428,18 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) { /* Leaves us with just the path */ std::string newfile = confpath.substr(0, pos) + std::string("/") + fname; + if (!FileExists(newfile.c_str())) + return false; file = fopen(newfile.c_str(), "r"); } } else + { + if (!FileExists(fname)) + return false; file = fopen(fname, "r"); + } if (file) { @@ -1460,11 +1466,16 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) bool ServerConfig::FileExists(const char* file) { + struct stat sb; + if (stat(file, &sb) == -1) + return false; + + if ((sb.st_mode & S_IFDIR) > 0) + return false; + FILE *input; if ((input = fopen (file, "r")) == NULL) - { return false; - } else { fclose(input); diff --git a/src/modules.cpp b/src/modules.cpp index 2818de639..83b88b2fa 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -718,12 +718,7 @@ bool ConfigReader::Verify() FileReader::FileReader(InspIRCd* Instance, const std::string &filename) : ServerInstance(Instance) { - file_cache c; - if (!ServerInstance->Config->ReadFile(c,filename.c_str())) - { - this->fc = c; - this->CalcSize(); - } + LoadFile(filename); } FileReader::FileReader(InspIRCd* Instance) : ServerInstance(Instance) |