[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen master] spapr-vty: Fix bad assert() statement



commit 7bacfd7f7289192c83330adceef9c38649c9acf9
Author:     Thomas Huth <thuth@xxxxxxxxxx>
AuthorDate: Thu Nov 10 21:16:01 2016 +0100
Commit:     David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
CommitDate: Tue Nov 15 10:08:43 2016 +1100

    spapr-vty: Fix bad assert() statement
    
    When using the serial console in the GTK interface of QEMU (and
    QEMU has been compiled with CONFIG_VTE), it is possible to trigger
    the assert() statement in vty_receive() in spapr_vty.c by pasting
    a chunk of text with length > 16 into the QEMU window.
    Most of the other serial backends seem to simply drop characters
    that they can not handle, so I think we should also do the same in
    spapr-vty to fix this issue.
    
    Buglink: https://bugs.launchpad.net/qemu/+bug/1639322
    Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
    Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
---
 hw/char/spapr_vty.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c
index 31822fe..06b9b39 100644
--- a/hw/char/spapr_vty.c
+++ b/hw/char/spapr_vty.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -37,7 +38,15 @@ static void vty_receive(void *opaque, const uint8_t *buf, 
int size)
         qemu_irq_pulse(spapr_vio_qirq(&dev->sdev));
     }
     for (i = 0; i < size; i++) {
-        assert((dev->in - dev->out) < VTERM_BUFSIZE);
+        if (dev->in - dev->out >= VTERM_BUFSIZE) {
+            static bool reported;
+            if (!reported) {
+                error_report("VTY input buffer exhausted - characters dropped."
+                             " (input size = %i)", size);
+                reported = true;
+            }
+            break;
+        }
         dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i];
     }
 }
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.