34cdd53
From 00837731d254908a841d69298a4f9f077babaf24 Mon Sep 17 00:00:00 2001
34cdd53
From: Stefan Weil <sw@weilnetz.de>
34cdd53
Date: Fri, 20 Nov 2015 08:42:33 +0100
34cdd53
Subject: [PATCH] eepro100: Prevent two endless loops
34cdd53
34cdd53
http://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg04592.html
34cdd53
shows an example how an endless loop in function action_command can
34cdd53
be achieved.
34cdd53
34cdd53
During my code review, I noticed a 2nd case which can result in an
34cdd53
endless loop.
34cdd53
34cdd53
Reported-by: Qinghao Tang <luodalongde@gmail.com>
34cdd53
Signed-off-by: Stefan Weil <sw@weilnetz.de>
34cdd53
Signed-off-by: Jason Wang <jasowang@redhat.com>
34cdd53
---
34cdd53
 tools/qemu-xen-traditional/hw/eepro100.c |   16 ++++++++++++++++
34cdd53
 1 files changed, 16 insertions(+), 0 deletions(-)
34cdd53
34cdd53
diff --git a/tools/qemu-xen-traditional/hw/eepro100.c b/tools/qemu-xen-traditional/hw/eepro100.c
34cdd53
index 60333b7..685a478 100644
34cdd53
--- a/tools/qemu-xen-traditional/hw/eepro100.c
34cdd53
+++ b/tools/qemu-xen-traditional/hw/eepro100.c
34cdd53
@@ -774,6 +774,11 @@ static void tx_command(EEPRO100State *s)
34cdd53
                 uint32_t tx_buffer_address = ldl_phys(tbd_address);
34cdd53
                 uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
34cdd53
                 //~ uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
34cdd53
+                if (tx_buffer_size == 0) {
34cdd53
+                    /* Prevent an endless loop. */
34cdd53
+                    logout("loop in %s:%u\n", __FILE__, __LINE__);
34cdd53
+                    break;
34cdd53
+                }
34cdd53
                 tbd_address += 8;
34cdd53
                 logout
34cdd53
                     ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
34cdd53
-- 
34cdd53
1.7.0.4
34cdd53