Bug 710975 - Bad index checking in nsIEProfileMigrator::TestForIE7(). r=gavin
authorTim Taubert <ttaubert@mozilla.com>
Sun, 08 Jan 2012 03:07:48 -0800
changeset 85241 371c513e15d71609bef93c88d0e476e3a73c5d9e
parent 85240 ffedccc6bf24c5c2a3fb6ee8a77c19606d3b4fd1
child 85242 9a230265bad5fb7d2c4ead3c9e4173081d8e90a7
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs710975
milestone12.0a1
Bug 710975 - Bad index checking in nsIEProfileMigrator::TestForIE7(). r=gavin
browser/components/migration/src/nsIEProfileMigrator.cpp
--- a/browser/components/migration/src/nsIEProfileMigrator.cpp
+++ b/browser/components/migration/src/nsIEProfileMigrator.cpp
@@ -94,16 +94,18 @@
 #include "nsBrowserCompsCID.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
 #include "nsToolkitCompsCID.h"
 #include "nsUnicharUtils.h"
 #include "nsIWindowsRegKey.h"
 #include "nsISupportsPrimitives.h"
 
+#define kNotFound -1
+
 #define TRIDENTPROFILE_BUNDLE       "chrome://browser/locale/migration/migration.properties"
 
 #define REGISTRY_IE_MAIN_KEY \
   NS_LITERAL_STRING("Software\\Microsoft\\Internet Explorer\\Main")
 #define REGISTRY_IE_TYPEDURL_KEY \
   NS_LITERAL_STRING("Software\\Microsoft\\Internet Explorer\\TypedURLs")
 #define REGISTRY_IE_TOOLBAR_KEY \
   NS_LITERAL_STRING("Software\\Microsoft\\Internet Explorer\\Toolbar")
@@ -597,37 +599,41 @@ nsIEProfileMigrator::TestForIE7()
 
   if (!::ExpandEnvironmentStringsW(iePath.get(), 
                                    destination, 
                                    bufLength)) 
     return false; 
 
   iePath = destination; 
 
+  // Check if the path is enclosed in quotation marks.
   if (StringBeginsWith(iePath, NS_LITERAL_STRING("\""))) {
     iePath.Cut(0,1);
-    PRUint32 index = iePath.FindChar('\"', 0);
+    PRInt32 index = iePath.FindChar('\"', 0);
+
+    // After removing the opening quoation mark,
+    // remove the closing one and everything after it.
     if (index > 0)
       iePath.Cut(index,iePath.Length());
   }
 
   nsCOMPtr<nsILocalFile> lf; 
   NS_NewLocalFile(iePath, true, getter_AddRefs(lf)); 
 
   nsCOMPtr<nsILocalFileWin> lfw = do_QueryInterface(lf); 
   if (!lfw)
    return false;
    
   nsAutoString ieVersion;
   if (NS_FAILED(lfw->GetVersionInfoField("FileVersion", ieVersion)))
    return false;
 
   if (ieVersion.Length() > 2) {
-    PRUint32 index = ieVersion.FindChar('.', 0);
-    if (index < 0)
+    PRInt32 index = ieVersion.FindChar('.', 0);
+    if (index == kNotFound)
       return false;
     ieVersion.Cut(index, ieVersion.Length());
     PRInt32 ver = wcstol(ieVersion.get(), nsnull, 0);
     if (ver >= 7) // Found 7 or greater major version
       return true;
   }
 
   return false;