qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] [M25P80] Make sure not to overrun the internal data buffer.
@ 2016-12-24 15:11 Jean-Christophe Dubois
  2016-12-24 17:18 ` mar.krzeminski
  0 siblings, 1 reply; 12+ messages in thread
From: Jean-Christophe Dubois @ 2016-12-24 15:11 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jean-Christophe Dubois

It did happen that the internal data buffer was overrun leading to a Qemu
crash (in particular while emulating the i.MX6 sabrelite board).

This patch makes sure the data array would not be overrun and allow the
sabrelite emulation to run without crash.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
---
 hw/block/m25p80.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index d29ff4c..a1c4e5d 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -1117,7 +1117,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
         s->data[s->len] = (uint8_t)tx;
         s->len++;
 
-        if (s->len == s->needed_bytes) {
+        if ((s->len >= s->needed_bytes) || (s->len >= sizeof(s->data))) {
             complete_collecting_data(s);
         }
         break;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-01-03 20:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-24 15:11 [Qemu-devel] [PATCH] [M25P80] Make sure not to overrun the internal data buffer Jean-Christophe Dubois
2016-12-24 17:18 ` mar.krzeminski
2016-12-24 17:41   ` Jean-Christophe DUBOIS
2016-12-24 18:04     ` mar.krzeminski
2016-12-24 18:12       ` Jean-Christophe DUBOIS
2016-12-27 17:08         ` Jean-Christophe DUBOIS
2016-12-30 15:39           ` mar.krzeminski
2016-12-30 17:14             ` Jean-Christophe DUBOIS
2016-12-30 18:09               ` mar.krzeminski
2017-01-02 21:24                 ` Jean-Christophe DUBOIS
2017-01-03 17:08                   ` mar.krzeminski
2017-01-03 20:34                     ` Jean-Christophe DUBOIS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).