video/hp1ll3: add runtime bounds check in CONF command (issue#3523) (nw) (#3547)

* video/hp1ll3: add runtime bounds check in CONF command (issue#3523) (nw)

* report unexpected CONF words if they are received (nw)
This commit is contained in:
Sergey Svishchev 2018-05-16 11:43:06 +03:00 committed by Vas Crabb
parent 680d9e1aeb
commit c7bda1bc2f
2 changed files with 16 additions and 12 deletions

View File

@ -47,7 +47,7 @@
* 0 -- no data
* 1 -- write 1 word of data, then command
* 2 -- write 2 words of data, then command
* 3 -- write command, then 11 words of data (= CONF only?)
* 3 -- write command, then 12 words of data (= CONF only?)
* 4 -- write 1 word of data, then command, then write X words of data, then write NOP
*
* (read)
@ -569,18 +569,22 @@ WRITE8_MEMBER( hp1ll3_device::write )
switch (m_command)
{
case CONF:
assert((m_conf_ptr >> 1) < ARRAY_LENGTH(m_conf));
if (m_conf_ptr & 1) {
m_conf[m_conf_ptr >> 1] |= data;
if (m_conf_ptr < 2 * ARRAY_LENGTH(m_conf)) {
if (m_conf_ptr & 1) {
m_conf[m_conf_ptr >> 1] |= data;
DBG_LOG(1,"HPGPU",("CONF data word %d received: %04X\n", m_conf_ptr >> 1, m_conf[m_conf_ptr >> 1]));
} else {
m_conf[m_conf_ptr >> 1] = data << 8;
}
} else {
m_conf[m_conf_ptr >> 1] = data << 8;
}
if (m_conf_ptr++ == 22) {
DBG_LOG(2,"HPGPU",("CONF data received: %04X %04X %04X %04X %04X %04X %04X %04X %04X %04X %04X\n",
m_conf[0], m_conf[1], m_conf[2], m_conf[3],
m_conf[4], m_conf[5], m_conf[6], m_conf[7],
m_conf[8], m_conf[9], m_conf[10]));
if (m_conf_ptr & 1) {
m_input[0] |= data;
DBG_LOG(1,"HPGPU",("unexpected CONF data word %d discarded: %04X\n", m_conf_ptr >> 1, m_input[0]));
} else {
m_input[0] = data << 8;
}
}
m_conf_ptr++;
break;
case WRMEM:

View File

@ -51,7 +51,7 @@ private:
void line(int x_from, int y_from, int x_to, int y_to);
void bitblt(int dstx, int dsty, uint16_t srcaddr, int width, int height, int op);
uint16_t m_conf[11], m_input[2];
uint16_t m_conf[12], m_input[2];
int m_input_ptr, m_memory_ptr, m_conf_ptr;
int m_command, m_horiz_pix_total, m_vert_pix_total;