From patchwork Mon Nov 12 15:15:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10678819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F20A1139B for ; Mon, 12 Nov 2018 15:22:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF9E929BDF for ; Mon, 12 Nov 2018 15:22:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D399B29D0B; Mon, 12 Nov 2018 15:22:04 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 8418729BDF for ; Mon, 12 Nov 2018 15:22:04 +0000 (UTC) Received: from localhost ([::1]:49187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gME2M-0008JO-HK for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Nov 2018 10:22:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMDwM-0002r5-V5 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMDwH-0001QB-1k for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46286) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMDwD-0001Nd-6Q for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:43 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30E9658E3F for ; Mon, 12 Nov 2018 15:15:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-158.ams2.redhat.com [10.36.116.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD9A71852E; Mon, 12 Nov 2018 15:15:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EA8075E16D; Mon, 12 Nov 2018 16:15:16 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 16:15:14 +0100 Message-Id: <20181112151516.10012-3-kraxel@redhat.com> In-Reply-To: <20181112151516.10012-1-kraxel@redhat.com> References: <20181112151516.10012-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 12 Nov 2018 15:15:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] edid: silence a stringop-overflow warning 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau Simplify the code that doesn't need strncpy() since length of string is already computed. /home/elmarco/src/qemu/hw/display/edid-generate.c: In function 'edid_desc_text': /home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy((char *)(desc + 5), text, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length computed here len = strlen(text); ^~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Marc-André Lureau Reviewed-by: Markus Armbruster Message-id: 20181110111623.31356-1-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- hw/display/edid-generate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index bdf5e1d4d4..77d9127344 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -165,7 +165,7 @@ static void edid_desc_text(uint8_t *desc, uint8_t type, if (len > 12) { len = 12; } - strncpy((char *)(desc + 5), text, len); + memcpy(desc + 5, text, len); desc[5 + len] = '\n'; }