diff options
author | ripsaw8080 <ripsaw8080@users.sourceforge.net> | 2022-06-10 09:51:31 +0300 |
---|---|---|
committer | kcgen <kcgen@users.noreply.github.com> | 2022-06-10 09:51:31 +0300 |
commit | 84a53a31fec7dfdbf2b38ea6f4367410be9f74b8 (patch) | |
tree | 46b709958a086f0fd12f322942e95639b9220bb4 | |
parent | edd513eca2acba3f9b260a4db2a9057bd4a47eb5 (diff) | |
parent | cbd06ec804b8c3395792ec8799cef9ad73f0ba94 (diff) |
Merge 'svn/trunk' r4478-4479kc/merge-r4479
-rw-r--r-- | src/cpu/core_full/op.h | 18 | ||||
-rw-r--r-- | src/cpu/core_full/optable.h | 2 | ||||
-rw-r--r-- | src/cpu/core_normal/prefix_66.h | 9 | ||||
-rw-r--r-- | src/cpu/core_normal/prefix_none.h | 9 | ||||
-rw-r--r-- | src/ints/bios_disk.cpp | 4 |
5 files changed, 27 insertions, 15 deletions
diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 1c7ca1f90..def6367eb 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -651,10 +651,20 @@ switch (inst.code.op) { #endif case O_BOUNDw: { - int16_t bound_min, bound_max; - bound_min=LoadMw(inst.rm_eaa); - bound_max=LoadMw(inst.rm_eaa+2); - if ( (((int16_t)inst_op1_w) < bound_min) || (((int16_t)inst_op1_w) > bound_max) ) { + if (inst.rm>=0xc0) goto illegalopcode; + const auto bound_min=LoadMws(inst.rm_eaa); + const auto bound_max=LoadMws(inst.rm_eaa+2); + if ( (inst_op1_ws < bound_min) || (inst_op1_ws > bound_max) ) { + EXCEPTION(5); + } + } + break; + case O_BOUNDd: + { + if (inst.rm>=0xc0) goto illegalopcode; + const auto bound_min=LoadMds(inst.rm_eaa); + const auto bound_max=LoadMds(inst.rm_eaa+4); + if ( (inst_op1_ds < bound_min) || (inst_op1_ds > bound_max) ) { EXCEPTION(5); } } diff --git a/src/cpu/core_full/optable.h b/src/cpu/core_full/optable.h index 608c13a9d..34029ddc0 100644 --- a/src/cpu/core_full/optable.h +++ b/src/cpu/core_full/optable.h @@ -448,7 +448,7 @@ static OpCode OpCodeTable[1024]={ /* 0x260 - 0x267 */ {D_PUSHAd ,0 ,0 ,0 },{D_POPAd ,0 ,0 ,0 }, -{L_MODRM ,O_BOUNDd ,0 ,0 },{0 ,0 ,0 ,0 }, +{L_MODRM ,O_BOUNDd ,0 ,M_Gd },{0 ,0 ,0 ,0 }, {L_PRESEG ,0 ,0 ,fs },{L_PRESEG ,0 ,0 ,gs }, {L_PREOP ,0 ,0 ,0 },{L_PREADD ,0 ,0 ,0 }, /* 0x268 - 0x26f */ diff --git a/src/cpu/core_normal/prefix_66.h b/src/cpu/core_normal/prefix_66.h index 7e92d7431..710521aa3 100644 --- a/src/cpu/core_normal/prefix_66.h +++ b/src/cpu/core_normal/prefix_66.h @@ -158,10 +158,11 @@ break; CASE_D(0x62) /* BOUND Ed */ { - int32_t bound_min, bound_max; - GetRMrd;GetEAa; - bound_min=LoadMd(eaa); - bound_max=LoadMd(eaa+4); + GetRMrd; + if (rm >= 0xc0) goto illegal_opcode; + GetEAa; + const auto bound_min=LoadMds(eaa); + const auto bound_max=LoadMds(eaa+4); if ( (((int32_t)*rmrd) < bound_min) || (((int32_t)*rmrd) > bound_max) ) { EXCEPTION(5); } diff --git a/src/cpu/core_normal/prefix_none.h b/src/cpu/core_normal/prefix_none.h index a28d56daa..5e5ec9c84 100644 --- a/src/cpu/core_normal/prefix_none.h +++ b/src/cpu/core_normal/prefix_none.h @@ -227,10 +227,11 @@ break; CASE_W(0x62) /* BOUND */ { - int16_t bound_min, bound_max; - GetRMrw;GetEAa; - bound_min=LoadMw(eaa); - bound_max=LoadMw(eaa+2); + GetRMrw; + if (rm >= 0xc0) goto illegal_opcode; + GetEAa; + const auto bound_min=LoadMws(eaa); + const auto bound_max=LoadMws(eaa+2); if ( (((int16_t)*rmrw) < bound_min) || (((int16_t)*rmrw) > bound_max) ) { EXCEPTION(5); } diff --git a/src/ints/bios_disk.cpp b/src/ints/bios_disk.cpp index c9f6bc8ae..f1313f4f2 100644 --- a/src/ints/bios_disk.cpp +++ b/src/ints/bios_disk.cpp @@ -380,8 +380,8 @@ static Bitu INT13_DiskHandler(void) { CALLBACK_SCF(true); return CBRET_NONE; } - if (drivenum < MAX_DISK_IMAGES && imageDiskList[drivenum] == nullptr) { - if (!Drives[drivenum] || Drives[drivenum]->isRemovable()) { + if (drivenum >= MAX_DISK_IMAGES || imageDiskList[drivenum] == nullptr) { + if (drivenum >= DOS_DRIVES || !Drives[drivenum] || Drives[drivenum]->isRemovable()) { reg_ah = 0x01; CALLBACK_SCF(true); return CBRET_NONE; |