From nobody Tue Feb 10 07:40:58 2026 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; dkim=fail; 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 152303588479891.83924611411601; Fri, 6 Apr 2018 10:31:24 -0700 (PDT) Received: from localhost ([::1]:41217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4VCt-0000St-Uh for importer@patchew.org; Fri, 06 Apr 2018 13:31:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4Uu2-00089j-21 for qemu-devel@nongnu.org; Fri, 06 Apr 2018 13:11:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4Utx-0007yg-5V for qemu-devel@nongnu.org; Fri, 06 Apr 2018 13:11:53 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:52276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f4Utw-0007wt-VP for qemu-devel@nongnu.org; Fri, 06 Apr 2018 13:11:49 -0400 Received: by mail-wm0-x241.google.com with SMTP id g8so4834676wmd.2 for ; Fri, 06 Apr 2018 10:11:48 -0700 (PDT) Received: from 640k.lan (94-36-194-48.adsl-ull.clienti.tiscali.it. [94.36.194.48]) by smtp.gmail.com with ESMTPSA id 24sm16286180wrt.60.2018.04.06.10.11.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 10:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y5vzB5cQl6cOLPHoUz6OLvaKt6tgnr34tm+qrydpYIY=; b=qCwJ21ygifKPjuyrXYHFrbnS+kH84unC70J0A5XlrJc0m1sR/3pOWXpRStmIVrxxGh OGc/VcJ2hFPD+BhoCf5SiI1wOGOOvYadedyu7y6gI4q3CM5HyJsbky3NC7oyUIBcUpXI KHV+BG3p0q72pwfXRrRfZCds2qTCULS4XY9c/jEhEabWS6K5WWXsLbJ6EJ/7xZjDVO1k bwOYWVPHrHTq4vP+6uKHaydGjAkh1NhCEypABfqc5Qc/MAr8yokAW7OHIYIPCBCanXkL 80Lt0I7qrVKootqlI4M2xAy042wi3lIYUCUqW5KGS7OoqCWWBS7/PMXOnUvPsL8EiFhj oPGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Y5vzB5cQl6cOLPHoUz6OLvaKt6tgnr34tm+qrydpYIY=; b=LX55P+/YSdIaW/cr/LiaWpVb0WTsQH6qA3F00yAPnJasQLwAKk1luOkvx/Xz5BMPJp JbNGpYRjg55P+XFbwRl9zgO+hPEpPRf4fGJ3BaNNbvmL1s5bYl9CjsPxXXabGUXSzyhL Bdg0SRpU//PAiQwcv6BDUdsNcxgsnYxrxqS0Ng5+Kl9hI7QJjuvys2F8vsMyePe8+9Ce olsNPe23ZYrCkkQKjV/SOLeyBJDczh82/9gtrFDpNPS5+JsIR229R3/vVYWnnljHydbl KtXS4dKlecIygqaFiLXWnIY0Gq+EEeP+WF/k2hmi7HiODVpQeWC0O74gtLm5n8M5uix7 Mccw== X-Gm-Message-State: ALQs6tBSMM6pm8aiby0N4jG+indYZa4emK6GZMJkAl2+VLNX6xnEd0FW 5s3nU38p5aMpDJZfEaILaQaE8FRv X-Google-Smtp-Source: AIpwx49R70wPlM2e8wb+oIRt3E46lryWOkMPo3wbF890gsyv8Z+7yK2Q3ypqwW24d+3wE0XaHgEHGg== X-Received: by 10.28.112.11 with SMTP id l11mr3132636wmc.31.1523034707570; Fri, 06 Apr 2018 10:11:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Apr 2018 19:11:19 +0200 Message-Id: <1523034681-33787-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523034681-33787-1-git-send-email-pbonzini@redhat.com> References: <1523034681-33787-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 18/20] dump: Fix build with newer gcc 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake gcc 8 on rawhide is picky enough to complain: /home/dummy/qemu/dump.c: In function 'create_header32': /home/dummy/qemu/dump.c:817:5: error: 'strncpy' output truncated before ter= minating nul copying 8 bytes from a string of the same length [-Werror=3Dst= ringop-truncation] strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ But we already have SIG_LEN defined as the right length without needing to do a strlen(), and memcpy() is better than strncpy() when we know we do not want a trailing NUL byte. Signed-off-by: Eric Blake Signed-off-by: Paolo Bonzini --- dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dump.c b/dump.c index 669f715..b54cd42 100644 --- a/dump.c +++ b/dump.c @@ -814,7 +814,7 @@ static void create_header32(DumpState *s, Error **errp) size =3D sizeof(DiskDumpHeader32); dh =3D g_malloc0(size); =20 - strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE)); + memcpy(dh->signature, KDUMP_SIGNATURE, SIG_LEN); dh->header_version =3D cpu_to_dump32(s, 6); block_size =3D s->dump_info.page_size; dh->block_size =3D cpu_to_dump32(s, block_size); @@ -926,7 +926,7 @@ static void create_header64(DumpState *s, Error **errp) size =3D sizeof(DiskDumpHeader64); dh =3D g_malloc0(size); =20 - strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE)); + memcpy(dh->signature, KDUMP_SIGNATURE, SIG_LEN); dh->header_version =3D cpu_to_dump32(s, 6); block_size =3D s->dump_info.page_size; dh->block_size =3D cpu_to_dump32(s, block_size); --=20 1.8.3.1