cf91b1d
From: Prasad J Pandit <pjp@fedoraproject.org>
cf91b1d
Date: Tue, 7 Jun 2016 16:44:03 +0530
cf91b1d
Subject: [PATCH] scsi: megasas: null terminate bios version buffer
cf91b1d
cf91b1d
While reading information via 'megasas_ctrl_get_info' routine,
cf91b1d
a local bios version buffer isn't null terminated. Add the
cf91b1d
terminating null byte to avoid any OOB access.
cf91b1d
cf91b1d
Reported-by: Li Qiang <liqiang6-s@360.cn>
cf91b1d
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
cf91b1d
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
cf91b1d
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cf91b1d
(cherry picked from commit 844864fbae66935951529408831c2f22367a57b6)
cf91b1d
---
cf91b1d
 hw/scsi/megasas.c | 1 +
cf91b1d
 1 file changed, 1 insertion(+)
cf91b1d
cf91b1d
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
cf91b1d
index cc66d36..a9ffc32 100644
cf91b1d
--- a/hw/scsi/megasas.c
cf91b1d
+++ b/hw/scsi/megasas.c
cf91b1d
@@ -773,6 +773,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
cf91b1d
 
cf91b1d
         ptr = memory_region_get_ram_ptr(&pci_dev->rom);
cf91b1d
         memcpy(biosver, ptr + 0x41, 31);
cf91b1d
+        biosver[31] = 0;
cf91b1d
         memcpy(info.image_component[1].name, "BIOS", 4);
cf91b1d
         memcpy(info.image_component[1].version, biosver,
cf91b1d
                strlen((const char *)biosver));