From nobody Tue Apr 30 00:52:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541848674475331.2960180966793; Sat, 10 Nov 2018 03:17:54 -0800 (PST) Received: from localhost ([::1]:37915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLRGj-0001Jb-Jv for importer@patchew.org; Sat, 10 Nov 2018 06:17:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLRFr-0000zF-Ra for qemu-devel@nongnu.org; Sat, 10 Nov 2018 06:16:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLRFm-00037S-Q6 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 06:16:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gLRFm-00030E-Jv for qemu-devel@nongnu.org; Sat, 10 Nov 2018 06:16:38 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFA4F394D52 for ; Sat, 10 Nov 2018 11:16:36 +0000 (UTC) Received: from localhost (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB67A6013F; Sat, 10 Nov 2018 11:16:31 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 15:16:23 +0400 Message-Id: <20181110111623.31356-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 10 Nov 2018 11:16:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH] 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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_t= ext': /home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' s= pecified bound depends on the length of the source argument [-Werror=3Dstri= ngop-overflow=3D] strncpy((char *)(desc + 5), text, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length comp= uted here len =3D strlen(text); ^~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- 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 =3D 12; } - strncpy((char *)(desc + 5), text, len); + memcpy(desc + 5, text, len); desc[5 + len] =3D '\n'; } =20 --=20 2.19.1.708.g4ede3d42df