diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 37615a32e..b89232a46 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -1031,8 +1031,8 @@ cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, int sector, int ismsf, int c memset(raw_buffer, 0, 2448); memset(extra_buffer, 0, 296); - if (!(cdrom_sector_flags & 0xf0)) { /* 0x00 and 0x08 are illegal modes */ - cdrom_log("CD-ROM %i: [Mode 1] 0x00 and 0x08 are illegal modes\n", dev->id); + if ((cdrom_sector_flags & 0xf8) == 0x08) { /* 0x08 is an illegal mode */ + cdrom_log("CD-ROM %i: [Mode 1] 0x08 is an illegal mode\n", dev->id); return 0; } diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index a53af6435..e099efe07 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -1626,8 +1626,14 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) msf = 1; + if ((cdb[9] & 0xf8) == 0x08) { + /* 0x08 is an illegal mode */ + scsi_cdrom_invalid_field(dev); + break; + } + /* If all the flag bits are cleared, then treat it as a non-data command. */ - if (cdb[9] == 0x00) + if ((cdb[9] == 0x00) && ((cdb[10] & 0x07) == 0x00)) dev->sector_len = 0; break; case GPCMD_READ_CD_OLD: @@ -1638,8 +1644,14 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) msf = 0; + if ((cdb[9] & 0xf8) == 0x08) { + /* 0x08 is an illegal mode */ + scsi_cdrom_invalid_field(dev); + break; + } + /* If all the flag bits are cleared, then treat it as a non-data command. */ - if (cdb[9] == 0x00) + if ((cdb[9] == 0x00) && ((cdb[10] & 0x07) == 0x00)) dev->sector_len = 0; break; }