aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Verkamp <daniel@drv.nu>2024-03-11 17:56:40 -0700
committerKevin O'Connor <kevin@koconnor.net>2024-03-12 10:27:40 -0400
commit3722c21de19ba64de56495502c0c025b913a9b15 (patch)
treeff22edad57ae0fb1546dcd535e07338f6aa9cde1
parent5d87ff2542c1116e07ae74ba84197a0013e08db1 (diff)
downloadseabios-3722c21de19ba64de56495502c0c025b913a9b15.tar.gz
vgasrc: round up save/restore size
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>
-rw-r--r--vgasrc/vbe.c2
-rw-r--r--vgasrc/vgabios.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c
index 91abc9ab..20437dba 100644
--- a/vgasrc/vbe.c
+++ b/vgasrc/vbe.c
@@ -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:
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index 198ee555..73ba1c3d 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -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;