nsDll::HasChanged does not check return from GetLastModifiedTime

RESOLVED FIXED in mozilla1.4alpha

Status

()

Core
XPCOM
RESOLVED FIXED
16 years ago
16 years ago

People

(Reporter: Andrew Schultz, Assigned: dougt)

Tracking

Trunk
mozilla1.4alpha
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
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.
(Assignee)

Comment 1

16 years ago
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;
 }
 
(Reporter)

Comment 2

16 years ago
looks great.
(Assignee)

Comment 3

16 years ago
Fix landed on the trunk this afternoon.
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.4alpha
You need to log in before you can comment on or make changes to this bug.