[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 20/23] jazz_led: fix bad snprintf
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 20/23] jazz_led: fix bad snprintf |
Date: |
Sun, 7 May 2017 10:02:23 +0300 |
From: Paolo Bonzini <address@hidden>
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 <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
hw/display/jazz_led.c | 4 ++--
1 file 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,
--
2.11.0
- [Qemu-trivial] [PULL 13/23] qemu-doc: Fix broken URLs of amnhltm.zip and dosidle210.zip, (continued)
- [Qemu-trivial] [PULL 13/23] qemu-doc: Fix broken URLs of amnhltm.zip and dosidle210.zip, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 04/23] Add 'none' as type for drive's if option, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 02/23] ppc_booke: drop useless assignment, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 07/23] device_tree: fix compiler warnings (clang 5), Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 18/23] scripts: Switch to more portable Perl shebang, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 22/23] MAINTAINERS: Update paths for AioContext implementation, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 10/23] block: Make 'replication_state' an enum, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 17/23] scripts/qemu-binfmt-conf.sh: Fix shell portability issue, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 05/23] tests: Ignore more test executables, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 03/23] doc: fix function spelling, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 20/23] jazz_led: fix bad snprintf,
Michael Tokarev <=
- [Qemu-trivial] [PULL 21/23] MAINTAINERS: Update paths for main loop, Michael Tokarev, 2017/05/07
- [Qemu-trivial] [PULL 16/23] virtfs: allow a device id to be specified in the -virtfs option, Michael Tokarev, 2017/05/07
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2017-05-07, no-reply, 2017/05/07
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2017-05-07, Stefan Hajnoczi, 2017/05/08