summary refs log tree commit diff stats
path: root/hw/display/jazz_led.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-05-03 12:44:41 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2017-05-10 10:19:24 +0300
commite9c6ab62c760e333a6cf0f3f9ab021633723434c (patch)
tree7788e085ba97b1ef7a65c62a93ee30083425a55f /hw/display/jazz_led.c
parentfafa2e6702a1ae4f094f8d5b79afef1e641ea3bb (diff)
downloadfocaccia-qemu-e9c6ab62c760e333a6cf0f3f9ab021633723434c.tar.gz
focaccia-qemu-e9c6ab62c760e333a6cf0f3f9ab021633723434c.zip
jazz_led: fix bad snprintf
Detected by GCC 7's -Wformat-truncation.  snprintf writes at most
2 bytes here including the terminating NUL, so the result is
truncated.  In addition, the newline at the end is pointless.
Fix the buffer size and the format string.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'hw/display/jazz_led.c')
-rw-r--r--hw/display/jazz_led.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index b72fdb1717..3c97d56434 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -227,13 +227,13 @@ static void jazz_led_invalidate_display(void *opaque)
 static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
 {
     LedState *s = opaque;
-    char buf[2];
+    char buf[3];
 
     dpy_text_cursor(s->con, -1, -1);
     qemu_console_resize(s->con, 2, 1);
 
     /* TODO: draw the segments */
-    snprintf(buf, 2, "%02hhx\n", s->segments);
+    snprintf(buf, 3, "%02hhx", s->segments);
     console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
                                              QEMU_COLOR_BLACK, 1));
     console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,