]> xenbits.xensource.com Git - seabios.git/commitdiff
block: Check for read/write requests over 64K
authorKevin O'Connor <kevin@koconnor.net>
Mon, 29 Dec 2014 15:29:34 +0000 (10:29 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 29 Dec 2014 15:36:46 +0000 (10:36 -0500)
The standard BIOS disk read/write request interface should never get a
request for more than 64K of data.  Explicitly check for overly large
requests and reject them.  This way, the low-level drivers do not need
to check for or attempt to handle very large requests.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/block.c
src/disk.c

index 43af305d9d781766f2bff8dcd05609fc0b980430..3f7ecb1d762d0c6d16f5c3cdbc4a6c033fee93e2 100644 (file)
@@ -485,6 +485,10 @@ process_op(struct disk_op_s *op)
 {
     ASSERT16();
     int ret, origcount = op->count;
+    if (origcount * GET_GLOBALFLAT(op->drive_gf->blksize) > 64*1024) {
+        op->count = 0;
+        return DISK_RET_EBOUNDARY;
+    }
     u8 type = GET_GLOBALFLAT(op->drive_gf->type);
     switch (type) {
     case DTYPE_FLOPPY:
index fe2e2c3165d7e8c2c05c3ac1aaab3f89eb9e5370..0e0af24b3bd56e8584582e9953e769116fa17e25 100644 (file)
@@ -173,6 +173,7 @@ disk_1300(struct bregs *regs, struct drive_s *drive_gf)
     struct disk_op_s dop;
     dop.drive_gf = drive_gf;
     dop.command = CMD_RESET;
+    dop.count = 0;
     int status = send_disk_op(&dop);
     disk_ret(regs, status);
 }
@@ -322,6 +323,7 @@ disk_1310(struct bregs *regs, struct drive_s *drive_gf)
     struct disk_op_s dop;
     dop.drive_gf = drive_gf;
     dop.command = CMD_ISREADY;
+    dop.count = 0;
     int status = send_disk_op(&dop);
     disk_ret(regs, status);
 }