Closed Bug 191250 Opened 22 years ago Closed 21 years ago

nsDll::HasChanged does not check return from GetLastModifiedTime

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.4alpha

People

(Reporter: ajschult784, Assigned: dougt)

Details

I noticed this because of a stale libgkcontent.so link in the components
directory.  The problem is that nsDll::HasChanged calls
m_dllSpec->GetLastModifiedTime, which returns NSRESULT_FOR_ERRNO(), but
HasChanged ignores the return value and proceeds even though currentDate is
bogus.  Valgrind reports this as:

Conditional jump or move depends on uninitialised value(s)
 nsNativeComponentLoader::AutoRegisterComponent() (nsNativeComponentLoader.cpp:774)
 nsNativeComponentLoader::RegisterComponentsInDir()
(nsNativeComponentLoader.cpp:240)
 nsNativeComponentLoader::AutoRegisterComponents() (nsNativeComponentLoader.cpp:180)
 nsComponentManagerImpl::AutoRegisterImpl() (nsComponentManager.cpp:3030)

to reproduce this, just make a bogus link in the components directory.
how is something like:

Index: xcDll.cpp
===================================================================
RCS file: /cvsroot/mozilla/xpcom/components/xcDll.cpp,v
retrieving revision 1.60
diff -u -1 -5 -r1.60 xcDll.cpp
--- xcDll.cpp	21 Jun 2002 19:58:47 -0000	1.60
+++ xcDll.cpp	30 Jan 2003 14:24:31 -0000
@@ -194,30 +194,32 @@
 PRBool
 nsDll::HasChanged()
 {
     if (m_dllName)
         return PR_FALSE;
 
     extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager*
*result);
     nsCOMPtr<nsIComponentLoaderManager> manager;
     NS_GetComponentLoaderManager(getter_AddRefs(manager));
     if (!manager)
         return PR_TRUE;
 
     // If mod date has changed, then dll has changed
     PRInt64 currentDate;
     nsresult rv = m_dllSpec->GetLastModifiedTime(&currentDate);
+    if (NS_FAILED(rv))
+        return PR_TRUE;
     PRBool changed = PR_TRUE;
     manager->HasFileChanged(m_dllSpec, nsnull, currentDate, &changed); 
     return changed;
 }
 
looks great.
Fix landed on the trunk this afternoon.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.4alpha
You need to log in before you can comment on or make changes to this bug.