mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
nscsi/cd.cpp: Fix some Coverity warnings in the nscsi_apple_cdrom_device. [R. Belmont]
This commit is contained in:
parent
4f10818b9b
commit
b598b7c1cc
21
src/devices/bus/nscsi/cd.cpp
Normal file → Executable file
21
src/devices/bus/nscsi/cd.cpp
Normal file → Executable file
@ -952,9 +952,9 @@ void nscsi_cdrom_apple_device::scsi_command()
|
||||
scsi_cmdbuf[2] = 0x01;
|
||||
scsi_cmdbuf[3] = 0x01;
|
||||
scsi_cmdbuf[4] = 0x31; // additional length
|
||||
strncpy((char *)&scsi_cmdbuf[8], "SONY ", 8);
|
||||
strncpy((char *)&scsi_cmdbuf[16], "CD-ROM CDU-8002 ", 16);
|
||||
strncpy((char *)&scsi_cmdbuf[32], "1.8g", 4);
|
||||
memcpy((char *)&scsi_cmdbuf[8], "SONY ", 8);
|
||||
memcpy((char *)&scsi_cmdbuf[16], "CD-ROM CDU-8002 ", 16);
|
||||
memcpy((char *)&scsi_cmdbuf[32], "1.8g", 4);
|
||||
scsi_cmdbuf[39] = 0xd0;
|
||||
scsi_cmdbuf[40] = 0x90;
|
||||
scsi_cmdbuf[41] = 0x27;
|
||||
@ -995,6 +995,10 @@ void nscsi_cdrom_apple_device::scsi_command()
|
||||
int pos = 0;
|
||||
|
||||
for (int trk = 0; trk < num_trks; trk++)
|
||||
{
|
||||
// Coverity: The emulated program could conceivably request a buffer size for
|
||||
// more tracks than exist, but we must still return the requested amount of data.
|
||||
if ((trk + start_track) < image->get_last_track())
|
||||
{
|
||||
const uint32_t start_lba = image->get_track_start(trk + start_track);
|
||||
const uint32_t start_frame = to_msf(start_lba);
|
||||
@ -1004,6 +1008,17 @@ void nscsi_cdrom_apple_device::scsi_command()
|
||||
scsi_cmdbuf[pos++] = dec_2_bcd(BIT(start_frame, 8, 8)); // seconds
|
||||
scsi_cmdbuf[pos++] = dec_2_bcd(BIT(start_frame, 0, 8)); // frames
|
||||
}
|
||||
else // keep returning the last track if necessary
|
||||
{
|
||||
const uint32_t start_lba = image->get_track_start(image->get_last_track());
|
||||
const uint32_t start_frame = to_msf(start_lba);
|
||||
|
||||
scsi_cmdbuf[pos++] = image->get_adr_control(image->get_last_track());
|
||||
scsi_cmdbuf[pos++] = dec_2_bcd(BIT(start_frame, 16, 8)); // minutes
|
||||
scsi_cmdbuf[pos++] = dec_2_bcd(BIT(start_frame, 8, 8)); // seconds
|
||||
scsi_cmdbuf[pos++] = dec_2_bcd(BIT(start_frame, 0, 8)); // frames
|
||||
}
|
||||
}
|
||||
|
||||
scsi_data_in(SBUF_MAIN, pos);
|
||||
scsi_status_complete(SS_GOOD);
|
||||
|
Loading…
Reference in New Issue
Block a user