Skip to contentSkip to conversation

Fix an overflow in term_puts

PATCH In review Anthony Liguori 1 participant 2 messages Jul 16, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 Fix an overflow in term_puts

Regards,

Anthony Liguori

# HG changeset patch
# User [email protected]
# Node ID 1cc1aeb53497fcc70843d8fb102da18f1af7e40e # Parent 0b4c6f94ee520884063f11f4631185368998cf9c Fix potential overflow in term_puts()

monitor.c +4 -1
diff -r 0b4c6f94ee52 -r 1cc1aeb53497 monitor.c
@@ -82,8 +82,11 @@
         c = *str++;
         if (c == '\0')
             break;
-        if (c == '\n')
+        if (c == '\n') {
             term_outbuf[term_outbuf_index++] = '\r';
+	    if (term_outbuf_index >= sizeof(term_outbuf) - 1)
+		term_flush();
+	}
         term_outbuf[term_outbuf_index++] = c;
         if (term_outbuf_index >= (sizeof(term_outbuf) - 1) ||
             c == '\n')
#1 lore raw

Nevermind on this one. I didn't catch that the - 1 actually prevents an overflow :-)

Regards,

Anthony Liguori

Quoted 23 lines · Anthony Liguori

Regards,

Anthony Liguori# HG changeset patch
# User [email protected]
# Node ID 1cc1aeb53497fcc70843d8fb102da18f1af7e40e # Parent 0b4c6f94ee520884063f11f4631185368998cf9c Fix potential overflow in term_puts()

diff -r 0b4c6f94ee52 -r 1cc1aeb53497 monitor.c --- a/monitor.c Sun Jul 16
16:25:28 2006 +++ b/monitor.c Sun Jul 16 16:26:39 2006 @@ -82,8 +82,11 @@

         c = *str++;
         if (c == '\0')
             break;
monitor.c +3 -1
-        if (c == '\n')
+        if (c == '\n') {
             term_outbuf[term_outbuf_index++] = '\r';
+	    if (term_outbuf_index >= sizeof(term_outbuf) - 1) +		term_flush();
+	}
         term_outbuf[term_outbuf_index++] = c; if (term_outbuf_index >=
         (sizeof(term_outbuf) - 1) ||
             c == '\n')_______________________________________________ Qemu-devel mailing list

[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel