Bläddra i källkod

Kernel: Refuse to set overflowy resolution values in BXVGADevice

Andreas Kling 5 år sedan
förälder
incheckning
fa40b725f9
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      Kernel/Devices/BXVGADevice.cpp

+ 4 - 0
Kernel/Devices/BXVGADevice.cpp

@@ -24,6 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  */
 
 
+#include <AK/Checked.h>
 #include <Kernel/Devices/BXVGADevice.h>
 #include <Kernel/Devices/BXVGADevice.h>
 #include <Kernel/PCI/Access.h>
 #include <Kernel/PCI/Access.h>
 #include <Kernel/Process.h>
 #include <Kernel/Process.h>
@@ -124,6 +125,9 @@ bool BXVGADevice::test_resolution(int width, int height)
 }
 }
 bool BXVGADevice::set_resolution(int width, int height)
 bool BXVGADevice::set_resolution(int width, int height)
 {
 {
+    if (Checked<int>::multiplication_would_overflow(width, height, sizeof(u32)))
+        return false;
+
     if (!test_resolution(width, height))
     if (!test_resolution(width, height))
         return false;
         return false;