mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
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:
11
Modules.cpp
11
Modules.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user