atirage: increase registers array and add boundary checks.

This commit is contained in:
Maxim Poliakovski 2021-02-05 01:22:28 +01:00
parent a5ef814ec4
commit 508ef2eaa9
2 changed files with 11 additions and 1 deletions

View File

@ -153,6 +153,11 @@ uint32_t ATIRage::read_reg(uint32_t offset, uint32_t size) {
read_mem(&this->block_io_regs[offset], size));
}
if (offset > sizeof(this->block_io_regs)) {
LOG_F(WARNING, "ATI Rage: register offset 0x%04X out of bounds!", offset);
return 0;
}
res = read_mem(&this->block_io_regs[offset], size);
return res;
@ -162,6 +167,11 @@ void ATIRage::write_reg(uint32_t offset, uint32_t value, uint32_t size) {
uint32_t gpio_val;
uint16_t gpio_dir;
if (offset > sizeof(this->block_io_regs)) {
LOG_F(WARNING, "ATI Rage: register offset 0x%04X out of bounds!", offset);
return;
}
/* size-dependent endian conversion */
write_mem(&this->block_io_regs[offset], value, size);

View File

@ -213,7 +213,7 @@ private:
// uint32_t atirage_cmdfifo_regs[3]; /* ATI Rage Command FIFO Registers */
// uint32_t atirage_datapath_regs[12]; /* ATI Rage Data Path Registers*/
uint8_t block_io_regs[256] = {0};
uint8_t block_io_regs[512] = {0};
uint8_t pci_cfg[256] = {0}; /* PCI configuration space */