Bug 978851 - LoadInfo::UpdateSystemLoad warns about format string in sscanf. r=padenot
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Thu, 06 Mar 2014 07:53:34 +0100
changeset 172180 0f81cbeae0d4acdb77bbb9e30533d8ca47409640
parent 172179 407e82dd7c3cce05427b98095b2026a3d36ba5bf
child 172191 4414ec1719aaf8592ba9f323ccc7a196985f200f
child 172301 e4c2bb65c694e39555ef6d2891e590f1dceefe45
push idunknown
push userunknown
push dateunknown
reviewerspadenot
bugs978851
milestone30.0a1
Bug 978851 - LoadInfo::UpdateSystemLoad warns about format string in sscanf. r=padenot
content/media/webrtc/LoadMonitor.cpp
--- a/content/media/webrtc/LoadMonitor.cpp
+++ b/content/media/webrtc/LoadMonitor.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "LoadMonitor.h"
 #include "nsString.h"
 #include "prlog.h"
 #include "prtime.h"
 #include "prinrval.h"
 #include "prsystem.h"
+#include "prprf.h"
 
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsReadableUtils.h"
 #include "nsNetUtil.h"
 #include "nsILineInputStream.h"
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
@@ -209,19 +210,19 @@ nsresult LoadInfo::UpdateSystemLoad()
   nsAutoCString buffer;
   bool isMore = true;
   lineInputStream->ReadLine(buffer, &isMore);
 
   uint64_t user;
   uint64_t nice;
   uint64_t system;
   uint64_t idle;
-  if (sscanf(buffer.get(), "cpu %Lu %Lu %Lu %Lu",
-             &user, &nice,
-             &system, &idle) != 4) {
+  if (PR_sscanf(buffer.get(), "cpu %llu %llu %llu %llu",
+                &user, &nice,
+                &system, &idle) != 4) {
     LOG(("Error parsing /proc/stat"));
     return NS_ERROR_FAILURE;
   }
 
   const uint64_t cpu_times = nice + system + user;
   const uint64_t total_times = cpu_times + idle;
 
   UpdateCpuLoad(total_times,