From: Daniel Verkamp Date: Tue, 12 Mar 2024 00:56:40 +0000 (-0700) Subject: vgasrc: round up save/restore size X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3722c21de19ba64de56495502c0c025b913a9b15;p=seabios.git 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 --- diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index 91abc9a..20437db 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 198ee55..73ba1c3 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;