Ver código fonte

Reject basic READ commands if the 2048-byte spec requirement is not met.

saybur 2 anos atrás
pai
commit
e8bde5e526
1 arquivos alterados com 15 adições e 5 exclusões
  1. 15 5
      src/BlueSCSI_cdrom.cpp

+ 15 - 5
src/BlueSCSI_cdrom.cpp

@@ -1095,7 +1095,7 @@ static void doMechanismStatus(uint16_t allocation_length)
 /*******************************************/
 
 static void doReadCD(uint32_t lba, uint32_t length, uint8_t sector_type,
-                     uint8_t main_channel, uint8_t sub_channel)
+                     uint8_t main_channel, uint8_t sub_channel, bool data_only)
 {
     image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 
@@ -1213,6 +1213,16 @@ static void doReadCD(uint32_t lba, uint32_t length, uint8_t sector_type,
         return;
     }
 
+    if (data_only && sector_length != 2048)
+    {
+        debuglog("------ Host tried to read non-data sector with standard READ command");
+        scsiDev.status = CHECK_CONDITION;
+        scsiDev.target->sense.code = ILLEGAL_REQUEST;
+        scsiDev.target->sense.asc = 0x6400; // ILLEGAL MODE FOR THIS TRACK
+        scsiDev.phase = STATUS;
+        return;
+    }
+
     bool field_q_subchannel = false;
     if (sub_channel == 2)
     {
@@ -1675,7 +1685,7 @@ extern "C" int scsiCDRomCommand()
         uint8_t main_channel = scsiDev.cdb[9];
         uint8_t sub_channel = scsiDev.cdb[10];
 
-        doReadCD(lba, blocks, sector_type, main_channel, sub_channel);
+        doReadCD(lba, blocks, sector_type, main_channel, sub_channel, false);
     }
     else if (command == 0xB9)
     {
@@ -1686,7 +1696,7 @@ extern "C" int scsiCDRomCommand()
         uint8_t main_channel = scsiDev.cdb[9];
         uint8_t sub_channel = scsiDev.cdb[10];
 
-        doReadCD(start, end - start, sector_type, main_channel, sub_channel);
+        doReadCD(start, end - start, sector_type, main_channel, sub_channel, false);
     }
     else if (command == 0x42)
     {
@@ -1711,7 +1721,7 @@ extern "C" int scsiCDRomCommand()
             (((uint32_t) scsiDev.cdb[7]) << 8) +
             scsiDev.cdb[8];
 
-        doReadCD(lba, blocks, 0, 0x10, 0);
+        doReadCD(lba, blocks, 0, 0x10, 0, true);
     }
     else if (command == 0xA8)
     {
@@ -1727,7 +1737,7 @@ extern "C" int scsiCDRomCommand()
             (((uint32_t) scsiDev.cdb[8]) << 8) +
             scsiDev.cdb[9];
 
-        doReadCD(lba, blocks, 0, 0x10, 0);
+        doReadCD(lba, blocks, 0, 0x10, 0, true);
     }
     else if (command == 0x4E)
     {