Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3036292imm; Mon, 28 May 2018 23:04:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZomy9ym0HZqus5V+HmJUGEvzKE1MLzv6zIgR15P2AcDvPd+NDsNOn3qEStIQTwk4Iccigm/ X-Received: by 2002:a63:6b43:: with SMTP id g64-v6mr12675331pgc.337.1527573881042; Mon, 28 May 2018 23:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527573881; cv=none; d=google.com; s=arc-20160816; b=BvZvQJXu73LqP3ZMBID2+dWJHmkzArvuttuCkExQKb8alqAlSKBllakjVS7fGDgGLg 61U50Ya3PWTNQpsukqDZLtl1N+gd2Ure/h1XKOg60Kosgc/hWRt6KC0+e5kqXyJkv+mS 0ip8RosJtmPPut0RnQDeOYhyWl0BLA+MveZKW9PHJBdVN/cKjtAuGJsW6E39cVyIGJWk j7TQHl2AE/85c+FcFgOLS89SpQUPBsJNhIM/inLX+NwqIw5nigy30KKVgZpt2veHpvz5 i60/sph5vHiQrJrC7qXSpiwSpMY2hdAQAqjwcwk2MjUEP/yDiDPdW7VrXEt2nAfQf+aQ +QAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :arc-authentication-results; bh=34V27LkpgwcnzxAGAAsopIFPH8frDbfa3AMcVG0xIdE=; b=UEMu/0Wb9CLcKdLnNPhtKYwYSsnjKkKnQUyQnFcYxCm2tCmx5E0F8lXx2kpdizNiNu w6o6bSy+chh5nF3PDGt2z4jcOREyiuPe1Jl1vJnJcL5Yhx01jEuR4QIXZAt7wJsx5lnT GAXyR6u9oFqn+gMgyVQ0eyJiuotF6tWcelULrH7to5f1drLcKyYd8yprGGgVvQntGs/F GcW71uqD5wqG2iwe4VEBwnUSL1uj5aV0/g/uFCOYNNe9hB3fXZYfbi8APAHsCKyV+YUO YbibKgygq8BuogWTpS7FUGdeojx+jpnF01A2Cxoxr3ceift2oh9g6lspNLeIyJ5kjMII F6fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b36-v6si32357565pli.30.2018.05.28.23.04.27; Mon, 28 May 2018 23:04:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754554AbeE2GD6 (ORCPT + 99 others); Tue, 29 May 2018 02:03:58 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:63931 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbeE2GDy (ORCPT ); Tue, 29 May 2018 02:03:54 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 40w37k2vX8z9ttRr; Tue, 29 May 2018 08:03:46 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id X9cH6QxNY31N; Tue, 29 May 2018 08:03:46 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 40w37k2Rgzz9ttCV; Tue, 29 May 2018 08:03:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8DEB78B78F; Tue, 29 May 2018 08:03:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id cmHhWMeM480h; Tue, 29 May 2018 08:03:53 +0200 (CEST) Received: from po14934vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6DFAD8B75A; Tue, 29 May 2018 08:03:53 +0200 (CEST) Received: by po14934vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 4A5616F6A3; Tue, 29 May 2018 06:03:53 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH v2] powerpc/64: Fix build failure with GCC 8.1 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 29 May 2018 06:03:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CC arch/powerpc/kernel/nvram_64.o arch/powerpc/kernel/nvram_64.c: In function 'nvram_create_partition': arch/powerpc/kernel/nvram_64.c:1042:2: error: 'strncpy' specified bound 12 equals destination size [-Werror=stringop-truncation] strncpy(new_part->header.name, name, 12); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC arch/powerpc/kernel/trace/ftrace.o In function 'make_field', inlined from 'ps3_repository_read_boot_dat_address' at arch/powerpc/platforms/ps3/repository.c:900:9: arch/powerpc/platforms/ps3/repository.c:106:2: error: 'strncpy' output truncated before terminating nul copying 8 bytes from a string of the same length [-Werror=stringop-truncation] strncpy((char *)&n, text, 8); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christophe Leroy --- v2: - Using strnlen(src, sizeof(dest)) instead of min(strlen(src), sizeof(dest)) - Changed nvram one to memcpy() to still fit the entire fied (thanks to benh) arch/powerpc/kernel/nvram_64.c | 2 +- arch/powerpc/platforms/ps3/repository.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c index ba681dac7b46..cf7772cdc3fd 100644 --- a/arch/powerpc/kernel/nvram_64.c +++ b/arch/powerpc/kernel/nvram_64.c @@ -1039,7 +1039,7 @@ loff_t __init nvram_create_partition(const char *name, int sig, new_part->index = free_part->index; new_part->header.signature = sig; new_part->header.length = size; - strncpy(new_part->header.name, name, 12); + memcpy(new_part->header.name, name, strnlen(name, sizeof(new_part->header.name))); new_part->header.checksum = nvram_checksum(&new_part->header); rc = nvram_write_header(new_part); diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 50dbaf24b1ee..e49c887787c4 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c @@ -101,9 +101,9 @@ static u64 make_first_field(const char *text, u64 index) static u64 make_field(const char *text, u64 index) { - u64 n; + u64 n = 0; - strncpy((char *)&n, text, 8); + memcpy((char *)&n, text, strnlen(text, sizeof(n))); return n + index; } -- 2.13.3