]> xenbits.xensource.com Git - osstest/seabios.git/commitdiff
vgasrc: round up save/restore size
authorDaniel Verkamp <daniel@drv.nu>
Tue, 12 Mar 2024 00:56:40 +0000 (17:56 -0700)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 12 Mar 2024 14:27:40 +0000 (10:27 -0400)
When calculating the size of the buffer required for the VGA/VBE state,
round up rather than truncating when dividing the number of bytes to get
the number of 64-byte blocks. Without this modification, the save state
function will write past the end of a buffer of the size requested.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
vgasrc/vbe.c
vgasrc/vgabios.c

index 91abc9abc6328811b1fa08874246b06357f869c7..20437dbaff78041973158f2ef95ffdb0635a1014 100644 (file)
@@ -244,7 +244,7 @@ vbe_104f04(struct bregs *regs)
     if (ret < 0)
         goto fail;
     if (cmd == 0)
-        regs->bx = ret / 64;
+        regs->bx = DIV_ROUND_UP(ret, 64);
     regs->ax = 0x004f;
     return;
 fail:
index 198ee5555584385e19a5ee6db4672f89dd0021a9..73ba1c3d72b45b607513e8c655f10611c01afd3f 100644 (file)
@@ -1081,7 +1081,7 @@ handle_101c(struct bregs *regs)
     if (ret < 0)
         goto fail;
     if (cmd == 0)
-        regs->bx = ret / 64;
+        regs->bx = DIV_ROUND_UP(ret, 64);
     regs->al = 0x1c;
 fail:
     return;