]> git.ipfire.org Git - thirdparty/qemu.git/commit
fw_cfg: avoid calculating invalid current entry pointer
authorGabriel L. Somlo <somlo@cmu.edu>
Thu, 5 Nov 2015 14:32:50 +0000 (09:32 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 17 Mar 2016 21:45:24 +0000 (16:45 -0500)
commit020282d3e640051405cfd246921413a894ce1dc1
treef4e9b92f01a90072f69024b9d81c3e7ec7391bbe
parent091af181047623695b7239cd8ddf928e1327b6a5
fw_cfg: avoid calculating invalid current entry pointer

When calculating a pointer to the currently selected fw_cfg item, the
following is used:

  FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];

When s->cur_entry is FW_CFG_INVALID, we are calculating the address of
a non-existent element in s->entries[arch][...], which is undefined.

This patch ensures the resulting entry pointer is set to NULL whenever
s->cur_entry is FW_CFG_INVALID.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Message-id: 1446733972-1602-5-git-send-email-somlo@cmu.edu
Cc: Marc MarĂ­ <markmb@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 66f8fd9dda312191b78d2a2ba2848bcee76127a2)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/nvram/fw_cfg.c