From nobody Fri May 3 03:18:40 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542727853049482.79626237648336; Tue, 20 Nov 2018 07:30:53 -0800 (PST) Received: from localhost ([::1]:34336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7zF-0005WD-Rp for importer@patchew.org; Tue, 20 Nov 2018 10:30:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7x1-0003wk-7R for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gP7wz-00059x-1o for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58443) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gP7wt-00055L-21; Tue, 20 Nov 2018 10:28:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB429307D91A; Tue, 20 Nov 2018 15:28:21 +0000 (UTC) Received: from localhost (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED20B60BF6; Tue, 20 Nov 2018 15:28:11 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 20 Nov 2018 19:27:51 +0400 Message-Id: <20181120152753.10463-2-marcandre.lureau@redhat.com> In-Reply-To: <20181120152753.10463-1-marcandre.lureau@redhat.com> References: <20181120152753.10463-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 20 Nov 2018 15:28:22 +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 for-3.1? 1/3] sheepdog: fix stringop-truncation 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: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Jeff Cody , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Liu Yuan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It seems adding an assert is enough to silence GCC. (sd_parse_snapid_or_tag() g_strlcpy() ensures that we don't get in that situation) ~/src/qemu/block/sheepdog.c: In function 'find_vdi_name': ~/src/qemu/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 eq= uals destination size [-Werror=3Dstringop-truncation] strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/sheepdog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/sheepdog.c b/block/sheepdog.c index 0125df9d49..f8877b611d 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1236,6 +1236,7 @@ static int find_vdi_name(BDRVSheepdogState *s, const = char *filename, * don't want the send_req to read uninitialized data. */ strncpy(buf, filename, SD_MAX_VDI_LEN); + assert(strlen(tag) < SD_MAX_VDI_TAG_LEN); strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); =20 memset(&hdr, 0, sizeof(hdr)); --=20 2.19.1.708.g4ede3d42df From nobody Fri May 3 03:18:40 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542727844223808.6279119774089; Tue, 20 Nov 2018 07:30:44 -0800 (PST) Received: from localhost ([::1]:34331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7z2-0005Fn-Tg for importer@patchew.org; Tue, 20 Nov 2018 10:30:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7x9-00044g-6t for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gP7x5-0005EM-8d for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gP7wz-00059Q-0m; Tue, 20 Nov 2018 10:28:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73F133082134; Tue, 20 Nov 2018 15:28:27 +0000 (UTC) Received: from localhost (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 197AC1001F52; Tue, 20 Nov 2018 15:28:25 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 20 Nov 2018 19:27:52 +0400 Message-Id: <20181120152753.10463-3-marcandre.lureau@redhat.com> In-Reply-To: <20181120152753.10463-1-marcandre.lureau@redhat.com> References: <20181120152753.10463-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 20 Nov 2018 15:28:27 +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 for-3.1? 2/3] migration: fix stringop-truncation 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: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Jeff Cody , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Liu Yuan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Adding an assert is enough to silence GCC. ~/src/qemu/migration/global_state.c: In function 'global_state_store_runnin= g': ~/src/qemu/migration/global_state.c:45:5: error: 'strncpy' specified bound = 100 equals destination size [-Werror=3Dstringop-truncation] strncpy((char *)global_state.runstate, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ state, sizeof(global_state.runstate)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors (alternatively, we could hard-code "running") Signed-off-by: Marc-Andr=C3=A9 Lureau --- migration/global_state.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/global_state.c b/migration/global_state.c index 8e8ab5c51e..01805c567a 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -42,6 +42,7 @@ int global_state_store(void) void global_state_store_running(void) { const char *state =3D RunState_str(RUN_STATE_RUNNING); + assert(strlen(state) < sizeof(global_state.runstate)); strncpy((char *)global_state.runstate, state, sizeof(global_state.runstate)); } --=20 2.19.1.708.g4ede3d42df From nobody Fri May 3 03:18:40 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 154272787300766.01747077510186; Tue, 20 Nov 2018 07:31:13 -0800 (PST) Received: from localhost ([::1]:34337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7zW-0005j0-VQ for importer@patchew.org; Tue, 20 Nov 2018 10:31:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7xT-0004QY-0v for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:29:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gP7xQ-0005YA-La for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gP7xH-0005QF-Bx; Tue, 20 Nov 2018 10:28:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B1C6C050DFB; Tue, 20 Nov 2018 15:28:46 +0000 (UTC) Received: from localhost (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3443660BF6; Tue, 20 Nov 2018 15:28:30 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 20 Nov 2018 19:27:53 +0400 Message-Id: <20181120152753.10463-4-marcandre.lureau@redhat.com> In-Reply-To: <20181120152753.10463-1-marcandre.lureau@redhat.com> References: <20181120152753.10463-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 20 Nov 2018 15:28:46 +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 for-3.1? 3/3] acpi: fix stringop-truncation warnings 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: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Jeff Cody , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Max Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Liu Yuan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace strcpy() that don't mind about having dest not ending with NUL char by qemu strpadcpy(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/acpi/aml-build.c | 6 ++++-- hw/acpi/core.c | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e43cd736d..0a64a23e09 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -24,6 +24,7 @@ #include "hw/acpi/aml-build.h" #include "qemu/bswap.h" #include "qemu/bitops.h" +#include "qemu/cutils.h" #include "sysemu/numa.h" =20 static GArray *build_alloc_array(void) @@ -1532,13 +1533,14 @@ build_header(BIOSLinker *linker, GArray *table_data, h->revision =3D rev; =20 if (oem_id) { - strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id); + strpadcpy((char *)h->oem_id, sizeof h->oem_id, oem_id, 0); } else { memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); } =20 if (oem_table_id) { - strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table= _id)); + strpadcpy((char *)h->oem_table_id, sizeof(h->oem_table_id), + oem_table_id, 0); } else { memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); memcpy(h->oem_table_id + 4, sig, 4); diff --git a/hw/acpi/core.c b/hw/acpi/core.c index aafdc61648..c1b4dfbfd9 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -31,6 +31,7 @@ #include "qapi/qapi-visit-misc.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qemu/cutils.h" =20 struct acpi_table_header { uint16_t _length; /* our length, not actual part of the hdr */ @@ -181,7 +182,7 @@ static void acpi_table_install(const char unsigned *blo= b, size_t bloblen, ext_hdr->_length =3D cpu_to_le16(acpi_payload_size); =20 if (hdrs->has_sig) { - strncpy(ext_hdr->sig, hdrs->sig, sizeof ext_hdr->sig); + strpadcpy(ext_hdr->sig, sizeof ext_hdr->sig, hdrs->sig, 0); ++changed_fields; } =20 @@ -200,12 +201,12 @@ static void acpi_table_install(const char unsigned *b= lob, size_t bloblen, ext_hdr->checksum =3D 0; =20 if (hdrs->has_oem_id) { - strncpy(ext_hdr->oem_id, hdrs->oem_id, sizeof ext_hdr->oem_id); + strpadcpy(ext_hdr->oem_id, sizeof ext_hdr->oem_id, hdrs->oem_id, 0= ); ++changed_fields; } if (hdrs->has_oem_table_id) { - strncpy(ext_hdr->oem_table_id, hdrs->oem_table_id, - sizeof ext_hdr->oem_table_id); + strpadcpy(ext_hdr->oem_table_id, sizeof ext_hdr->oem_table_id, + hdrs->oem_table_id, 0); ++changed_fields; } if (hdrs->has_oem_rev) { @@ -213,8 +214,8 @@ static void acpi_table_install(const char unsigned *blo= b, size_t bloblen, ++changed_fields; } if (hdrs->has_asl_compiler_id) { - strncpy(ext_hdr->asl_compiler_id, hdrs->asl_compiler_id, - sizeof ext_hdr->asl_compiler_id); + strpadcpy(ext_hdr->asl_compiler_id, sizeof ext_hdr->asl_compiler_i= d, + hdrs->asl_compiler_id, 0); ++changed_fields; } if (hdrs->has_asl_compiler_rev) { --=20 2.19.1.708.g4ede3d42df