aboutsummaryrefslogtreecommitdiffstats
path: root/sample/mdiskchk.c
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-29 21:35:17 +0000
committerhpa <hpa>2004-12-29 21:35:17 +0000
commit98321f6e4e86407c5ee39af8bbd2344d089efa19 (patch)
tree1ca5df634e0b07ea136ae765c21f0ff0749473cd /sample/mdiskchk.c
parent0cce800e1e60c14fb952124e9014eb6abd07f04e (diff)
downloadsyslinux-98321f6e4e86407c5ee39af8bbd2344d089efa19.tar.gz
syslinux-98321f6e4e86407c5ee39af8bbd2344d089efa19.tar.xz
syslinux-98321f6e4e86407c5ee39af8bbd2344d089efa19.zip
Correctly handle different values of the memdisk info structure
Diffstat (limited to 'sample/mdiskchk.c')
-rw-r--r--sample/mdiskchk.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sample/mdiskchk.c b/sample/mdiskchk.c
index f48263bf..fb8616cc 100644
--- a/sample/mdiskchk.c
+++ b/sample/mdiskchk.c
@@ -55,6 +55,7 @@ struct memdiskinfo * query_memdisk(int drive)
uint32_t _eax, _ebx, _ecx, _edx;
uint16_t _es, _di;
unsigned char _dl = drive;
+ uint16_t bytes;
__asm {
.386 ;
@@ -78,7 +79,16 @@ struct memdiskinfo * query_memdisk(int drive)
_ebx >> 16 != 0x4b53 )
return NULL;
- _fmemcpy((void far *)&mm, (void far *)MK_FP(_es,_di), 26);
+ memset(&mm, 0, sizeof mm);
+
+ bytes = *(uint16_t far *)MK_FP(_es, _di);
+
+ /* 27 is the most we know how to handle */
+ if ( bytes > 27 )
+ bytes = 27;
+
+ _fmemcpy((void far *)&mm, (void far *)MK_FP(_es,_di), bytes);
+
mm.cylinders = ((_ecx >> 8) & 0xff) + ((_ecx & 0xc0) << 2) + 1;
mm.heads = ((_edx >> 8) & 0xff) + 1;
mm.sectors = (_ecx & 0x3f);