From 109ece2de6b2e4f89837fd7a32616120e424b488 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 16 Nov 2009 18:11:53 +0000 Subject: [PATCH] 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 --- Modules.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Modules.cpp b/Modules.cpp index 309f3723..202fdad9 100644 --- a/Modules.cpp +++ b/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;