From patchwork Sun May 7 07:02:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 9715209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E3C8602A0 for ; Sun, 7 May 2017 07:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ED4B2841C for ; Sun, 7 May 2017 07:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0270D2847D; Sun, 7 May 2017 07:41:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B04182841C for ; Sun, 7 May 2017 07:41:56 +0000 (UTC) Received: from localhost ([::1]:54025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7GpH-0001RB-WD for patchwork-qemu-devel@patchwork.kernel.org; Sun, 07 May 2017 03:41:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7Go1-0001Pf-FO for qemu-devel@nongnu.org; Sun, 07 May 2017 03:40:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7Gny-00072H-Dp for qemu-devel@nongnu.org; Sun, 07 May 2017 03:40:37 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:41363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7Gny-00071f-5j; Sun, 07 May 2017 03:40:34 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 81A4740481; Sun, 7 May 2017 10:40:32 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with SMTP id 8ABDF437; Sun, 7 May 2017 10:02:31 +0300 (MSK) Received: (nullmailer pid 26579 invoked by uid 1000); Sun, 07 May 2017 07:02:29 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Sun, 7 May 2017 10:02:23 +0300 Message-Id: <8d152b536ef6b40d51901ae650d72a4afb794e80.1494140528.git.mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 20/23] jazz_led: fix bad snprintf X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Paolo Bonzini , Michael Tokarev Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini 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 Reviewed-by: Markus Armbruster Reviewed-by: Laurent Vivier Signed-off-by: Michael Tokarev --- 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,