From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRRpE-0006if-1C for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRRpD-0005Lk-33 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRRpC-0005LU-UQ for qemu-devel@nongnu.org; Thu, 04 Feb 2016 16:52:27 -0500 Date: Thu, 4 Feb 2016 23:52:22 +0200 From: "Michael S. Tsirkin" Message-ID: <1454612376-7072-22-git-send-email-mst@redhat.com> References: <1454612376-7072-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1454612376-7072-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 21/49] ipmi: fix SDR length value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Eduardo Habkost , Corey Minyard , =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwTGU9MjBHb2F0ZXI/PQ==?= , Marcel Apfelbaum , Greg Kurz From: C=E9dric Le Goater The IPMI BMC simulator populates the SDR table with a set of initial SDRs. The length of each SDR is taken from the record itself (byte 4) which does not include the size of the header. But, the full length (header + data) is required by the sdr_add_entry() routine. Signed-off-by: C=E9dric Le Goater Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index d8ca76a..73a4f6a 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -356,7 +356,7 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t reci= d, =20 while (pos < sdr->next_free) { uint16_t trec =3D sdr->sdr[pos] | (sdr->sdr[pos + 1] << 8); - unsigned int nextpos =3D pos + sdr->sdr[pos + 4]; + unsigned int nextpos =3D pos + sdr->sdr[pos + 4] + 5; =20 if (trec =3D=3D recid) { if (nextrec) { @@ -1164,7 +1164,7 @@ static void get_sdr(IPMIBmcSim *ibs, rsp[2] =3D IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } - if (cmd[6] > (ibs->sdr.sdr[pos + 4])) { + if (cmd[6] > (ibs->sdr.sdr[pos + 4] + 5)) { rsp[2] =3D IPMI_CC_PARM_OUT_OF_RANGE; return; } @@ -1173,7 +1173,7 @@ static void get_sdr(IPMIBmcSim *ibs, IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff); =20 if (cmd[7] =3D=3D 0xff) { - cmd[7] =3D ibs->sdr.sdr[pos + 4] - cmd[6]; + cmd[7] =3D ibs->sdr.sdr[pos + 4] + 5 - cmd[6]; } =20 if ((cmd[7] + *rsp_len) > max_rsp_len) { @@ -1647,17 +1647,17 @@ static void ipmi_sim_init(Object *obj) error_report("Problem with recid 0x%4.4x", i); return; } - len =3D init_sdrs[i + 4]; + len =3D init_sdrs[i + 4] + 5; recid =3D init_sdrs[i] | (init_sdrs[i + 1] << 8); if (recid =3D=3D 0xffff) { break; } - if ((i + len + 5) > sizeof(init_sdrs)) { + if ((i + len) > sizeof(init_sdrs)) { error_report("Problem with recid 0x%4.4x", i); return; } sdr_add_entry(ibs, init_sdrs + i, len, NULL); - i +=3D len + 5; + i +=3D len; } =20 ipmi_init_sensors_from_sdrs(ibs); --=20 MST