Bug 498379: Checking that we aren't updating to an older version of the application fails in certain cases. r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 15 Jun 2009 20:48:30 +0100
changeset 29247 1224a2fdf8269709f1ae277f8098c07e8045093c
parent 29246 d18a8082a617ae12eab7e868592c30a98b759f94
child 29248 7c5925e88037fe09aa27364e118330cb6971df4c
push id7509
push userdtownsend@mozilla.com
push dateMon, 15 Jun 2009 19:53:44 +0000
treeherdermozilla-central@1224a2fdf826 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobstrong
bugs498379
milestone1.9.2a1pre
Bug 498379: Checking that we aren't updating to an older version of the application fails in certain cases. r=robstrong
toolkit/xre/nsUpdateDriver.cpp
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -298,16 +298,21 @@ IsOlderVersion(nsILocalFile *versionFile
     return PR_TRUE;
 
   char buf[32];
   char *result = fgets(buf, sizeof(buf), fp);
   fclose(fp);
   if (!result)
     return PR_TRUE;
 
+  // Trim off any trailing newline
+  int len = strlen(result);
+  if (len > 0 && result[len - 1] == '\n')
+    result[len - 1] = '\0';
+
   // If the update xml doesn't provide the application version the file will
   // contain the string "null" and it is assumed that the update is not older.
   const char kNull[] = "null";
   if (strncmp(buf, kNull, sizeof(kNull) - 1) == 0)
     return PR_FALSE;
 
   if (NS_CompareVersions(appVersion, result) > 0)
     return PR_TRUE;