Title: [232929] trunk/Source/WebCore
Revision
232929
Author
[email protected]
Date
2018-06-18 06:43:26 -0700 (Mon, 18 Jun 2018)

Log Message

Properly check the sscanf return valua
https://bugs.webkit.org/show_bug.cgi?id=186757

Reviewed by Carlos Garcia Campos.

Check if we matched anything and if we matched the expected amount of
data.

* page/linux/ResourceUsageThreadLinux.cpp:
(WebCore::cpuPeriod):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232928 => 232929)


--- trunk/Source/WebCore/ChangeLog	2018-06-18 13:35:58 UTC (rev 232928)
+++ trunk/Source/WebCore/ChangeLog	2018-06-18 13:43:26 UTC (rev 232929)
@@ -1,5 +1,18 @@
 2018-06-18  Tomas Popela  <[email protected]>
 
+        Properly check the sscanf return valua
+        https://bugs.webkit.org/show_bug.cgi?id=186757
+
+        Reviewed by Carlos Garcia Campos.
+
+        Check if we matched anything and if we matched the expected amount of
+        data.
+
+        * page/linux/ResourceUsageThreadLinux.cpp:
+        (WebCore::cpuPeriod):
+
+2018-06-18  Tomas Popela  <[email protected]>
+
         [GTK] Wrong variable used in RenderThemeGtk
         https://bugs.webkit.org/show_bug.cgi?id=186756
 

Modified: trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp (232928 => 232929)


--- trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp	2018-06-18 13:35:58 UTC (rev 232928)
+++ trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp	2018-06-18 13:43:26 UTC (rev 232929)
@@ -58,9 +58,15 @@
     unsigned long long userTime, niceTime, systemTime, idleTime;
     unsigned long long ioWait, irq, softIrq, steal, guest, guestnice;
     ioWait = irq = softIrq = steal = guest = guestnice = 0;
-    sscanf(buffer, "cpu  %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
+    int retVal = sscanf(buffer, "cpu  %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
         &userTime, &niceTime, &systemTime, &idleTime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
+    // We expect 10 values to be matched by sscanf
+    if (retVal < 10 || retVal == EOF) {
+        fclose(file);
+        return 0;
+    }
 
+
     // Keep parsing if we still don't know cpuCount.
     static unsigned cpuCount = 0;
     if (!cpuCount) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to