Bug 656331 - XPCOM binary component loading never checks mVersion, r=bz
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 11 May 2011 13:03:38 -0400
changeset 68115 036380520767a9c7da4c816a0259cb2dc4e47915
parent 68114 b0096e6a2bd43193d291752044a5d60605991a86
child 68116 bada2f37fecd4706092ba9eaa9532bf1091241d8
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs656331
milestone5.0a2
Bug 656331 - XPCOM binary component loading never checks mVersion, r=bz
xpcom/components/Module.h
xpcom/components/nsNativeComponentLoader.cpp
--- a/xpcom/components/Module.h
+++ b/xpcom/components/Module.h
@@ -48,17 +48,17 @@ namespace mozilla {
 /**
  * A module implements one or more XPCOM components. This structure is used
  * for both binary and script modules, but the registration members
  * (cids/contractids/categoryentries) are unused for modules which are loaded
  * via a module loader.
  */
 struct Module
 {
-  static const int kVersion = 2;
+  static const unsigned int kVersion = 2;
 
   struct CIDEntry;
 
   typedef already_AddRefed<nsIFactory> (*GetFactoryProcPtr)
     (const Module& module, const CIDEntry& entry);
 
   typedef nsresult (*ConstructorProcPtr)(nsISupports* aOuter,
                                          const nsIID& aIID,
--- a/xpcom/components/nsNativeComponentLoader.cpp
+++ b/xpcom/components/nsNativeComponentLoader.cpp
@@ -199,17 +199,18 @@ nsNativeModuleLoader::LoadModule(nsILoca
 
         free(blist);
     }
 #endif
 
     void *module = PR_FindSymbol(data.library, "NSModule");
     if (module) {
         data.module = *(mozilla::Module const *const *) module;
-        if (mLibraries.Put(hashedFile, data))
+        if (mozilla::Module::kVersion == data.module->mVersion &&
+            mLibraries.Put(hashedFile, data))
             return data.module;
     }
     else {
         LOG(PR_LOG_ERROR,
             ("nsNativeModuleLoader::LoadModule(\"%s\") - "
              "Symbol NSModule not found", filePath.get()));
     }