From patchwork Wed Nov 21 14:27:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Bishop X-Patchwork-Id: 1001179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 430QD96GpBz9s3l for ; Thu, 22 Nov 2018 01:38:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fuzziesquirrel.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 430QD93Xx8zF3fV for ; Thu, 22 Nov 2018 01:38:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fuzziesquirrel.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=fuzziesquirrel.com (client-ip=173.167.31.197; helo=bajor.fuzziesquirrel.com; envelope-from=bradleyb@fuzziesquirrel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fuzziesquirrel.com X-Greylist: delayed 596 seconds by postgrey-1.36 at bilbo; Thu, 22 Nov 2018 01:38:12 AEDT Received: from bajor.fuzziesquirrel.com (mail.fuzziesquirrel.com [173.167.31.197]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 430QD43RyGzF3f8 for ; Thu, 22 Nov 2018 01:38:12 +1100 (AEDT) X-Virus-Scanned: amavisd-new at fuzziesquirrel.com From: Brad Bishop To: skiboot@lists.ozlabs.org Date: Wed, 21 Nov 2018 09:27:53 -0500 Message-Id: <20181121142753.25523-1-bradleyb@fuzziesquirrel.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH] libffs: fix gcc8 stringop-truncation warnings X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Copy the null byte too in this copy operation to avoid the following warning: | libflash/libffs.c: In function 'ffs_part_info': | libflash/libffs.c:525:3: error: 'strncpy' output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation] | strncpy(n, ent->name, FFS_PART_NAME_MAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Brad Bishop --- libflash/libffs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libflash/libffs.c b/libflash/libffs.c index 221c2b02..816153d3 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -522,7 +522,7 @@ int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx, n = calloc(1, FFS_PART_NAME_MAX + 1); if (!n) return FLASH_ERR_MALLOC_FAILED; - strncpy(n, ent->name, FFS_PART_NAME_MAX); + strncpy(n, ent->name, FFS_PART_NAME_MAX +1); *name = n; } return 0;