Permalink
Browse files

Fix check not to truncate if offset is page aligned, which also preve…

…nts truncating to zero accidentally
  • Loading branch information...
joncampbell123 committed Apr 7, 2018
1 parent 09745e3 commit e5b5dee3be99337035b14ff3a5cfe817ed95ee2c
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/dos/dos.cpp
View
@@ -1156,7 +1156,7 @@ static Bitu DOS_21Handler(void) {
* if we do not do this.
*
* Ref: http://files.scene.org/get/mirrors/hornet/demos/1995/d/darkp.zip */
if (((uint32_t)toread+(uint32_t)reg_dx) > 0xFFFFUL) {
if (((uint32_t)toread+(uint32_t)reg_dx) > 0xFFFFUL && (reg_dx & 0xFU) != 0U) {
Bit16u nuread = (Bit16u)(0x10000UL - (reg_dx & 0xF)); /* FIXME: If MS-DOS 5.0 truncates it any farther I need to know! */
if (nuread > toread) nuread = toread;
@@ -1189,7 +1189,7 @@ static Bitu DOS_21Handler(void) {
* This is copy-paste of AH=3Fh read handling because it's likely
* that MS-DOS probably does the same with write as well, though
* this has not yet been confirmed. --J.C. */
if (((uint32_t)towrite+(uint32_t)reg_dx) > 0xFFFFUL) {
if (((uint32_t)towrite+(uint32_t)reg_dx) > 0xFFFFUL && (reg_dx & 0xFU) != 0U) {
Bit16u nuwrite = (Bit16u)(0x10000UL - (reg_dx & 0xF)); /* FIXME: If MS-DOS 5.0 truncates it any farther I need to know! */
if (nuwrite > towrite) nuwrite = towrite;

0 comments on commit e5b5dee

Please sign in to comment.