aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2010-09-20 18:26:59 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2010-09-20 18:26:59 -0700
commit61c1ba393851daf31022e27813f38e9bfb52e3ff (patch)
tree108f938d9b9b41c7b19ba8e907a34972db9849d4
parent2b789e77376ecab7ab8775ac30dae7b6f090d62d (diff)
downloadcontrib-master_new.tar.gz
contrib-master_new.tar.xz
contrib-master_new.zip
gpllib: disk: cap the number of sectors per writemaster_new
The core silently caps the number of sectors to write per call at 127. Surface the error to the caller by doing explicitely the check. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
-rw-r--r--com32/gpllib/disk/write.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/com32/gpllib/disk/write.c b/com32/gpllib/disk/write.c
index b1b12e06..a3ba0416 100644
--- a/com32/gpllib/disk/write.c
+++ b/com32/gpllib/disk/write.c
@@ -22,6 +22,8 @@
#include <disk/util.h>
#include <disk/write.h>
+#define MAX_TRANSFER 127
+
/**
* write_sectors - write several sectors from disk
* @drive_info: driveinfo struct describing the disk
@@ -39,6 +41,10 @@ int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
struct ebios_dapa *dapa = __com32.cs_bounce;
void *buf = (char *)__com32.cs_bounce + SECTOR * size;
+ // The core caps at 127 sectors per call
+ if (size > MAX_TRANSFER)
+ return -1;
+
memcpy(buf, data, SECTOR * size);
memset(&inreg, 0, sizeof inreg);