diff options
author | hpa <hpa> | 2004-12-29 21:35:17 +0000 |
---|---|---|
committer | hpa <hpa> | 2004-12-29 21:35:17 +0000 |
commit | 98321f6e4e86407c5ee39af8bbd2344d089efa19 (patch) | |
tree | 1ca5df634e0b07ea136ae765c21f0ff0749473cd | |
parent | 0cce800e1e60c14fb952124e9014eb6abd07f04e (diff) | |
download | syslinux-98321f6e4e86407c5ee39af8bbd2344d089efa19.tar.gz |
Correctly handle different values of the memdisk info structure
-rw-r--r-- | sample/mdiskchk.c | 12 | ||||
-rwxr-xr-x | sample/mdiskchk.com | bin | 9648 -> 9680 bytes |
2 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); diff --git a/sample/mdiskchk.com b/sample/mdiskchk.com Binary files differindex 388217b9..572cae75 100755 --- a/sample/mdiskchk.com +++ b/sample/mdiskchk.com |