CModules::OpenModule(): Check the version number first

At the time that OpenModule() verified that the module's version number matched
the version of the currently running ZNC, it had already called two of the
functions exported from the module.

Reorder this so that we don't do *any* other calls if we get a version mismatch.

Thanks to KiNgMaR for noticing this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1663 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-11-16 18:11:53 +00:00
parent 3ffa684ebf
commit 7c7f49ec78
+8 -3
View File
@@ -1013,6 +1013,12 @@ CModules::ModDirList CModules::GetModDirs() {
ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, bool &bVersionMismatch,
bool &bIsGlobal, CString& sDesc, CString& sRetMsg) {
// Some sane defaults in case anything errors out below
bVersionMismatch = false;
bIsGlobal = false;
sDesc.clear();
sRetMsg.clear();
for (unsigned int a = 0; a < sModule.length(); a++) {
if (((sModule[a] < '0') || (sModule[a] > '9')) && ((sModule[a] < 'a') || (sModule[a] > 'z')) && ((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) {
sRetMsg = "Module names can only contain letters, numbers and underscores, [" + sModule + "] is invalid.";
@@ -1054,15 +1060,14 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return false;
}
bIsGlobal = IsGlobal();
sDesc = GetDesc();
if (CModule::GetCoreVersion() != Version()) {
bVersionMismatch = true;
sRetMsg = "Version mismatch, recompile this module.";
} else {
sRetMsg = "";
bVersionMismatch = false;
bIsGlobal = IsGlobal();
sDesc = GetDesc();
}
return p;