Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp533717pxf; Thu, 18 Mar 2021 06:36:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOZQzRjp24zWJD5OqWFaCUbCLsmTBAbY/tB1t8NwJvh+B+yaHcxhJ8KQfLNB2vkOs5LErS X-Received: by 2002:a05:6402:2d0:: with SMTP id b16mr3776150edx.194.1616074576790; Thu, 18 Mar 2021 06:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616074576; cv=none; d=google.com; s=arc-20160816; b=pH+3hktGCkg0tEMhgftBdIG8rs6MZ/PSwAS5DP972SyZzl/UYm5YFQvmdhoxZFoNLg XQHkBRmFX5s1RurEe2zLYFm6dtZ/6zdmckOtHxir2EWltKTd4vHSA8D2GXcZRlc5VZJh th55LahdyqxEnOEeKJ7Dz+etCFzlAcMaTw3b8MpAUTMAOdbQB/J2ZzcfHGrS+ONqTnqh O1FoPoGKo2qChIfVjFcjGlaazSWwDHK0GS16EEWv9cZ6uoADNBDmI4r/h3cOtdyF2nVD ymneNFpjbf/65cjBHAcdDfSZ1ijgdRrynuPaZmbJzLLpPA61hQF3zxbDw2OmSBtZAi9a yYpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mzhXuCduUUpG2z/geC/W8iFWru0UNAtaotQs3FcTdok=; b=rZlV+UAbrGNbX0MA+z53Q/ufshm61J4XOR/LkbGnEBdlI2Tps0nWFNiFrrl56MOEZj ducZY7ckhZwR29vhPBp3zr2JpsC0EnoeyPKI3txdBB3qJmPY0qhlktaNNB5WzOepMkmI ODpBCeNs9IpEvPp6UKUnjQn/9iiu8Of0w7MDiu0VN4sW32pHTJ/6TAT+79Sa52+BVBNo k1BnRqnINt4j++S4bgVzFk9Hlf4snsk2n/woVkwC9iDwZExDi7zmBKyShp7XyKjrf3x0 z99h+uQ3l0IAvRjlpty4xnSdv76C/I84L8PKKDHYyKAVKwinHRrrQ/NTgFkerfn/t7s0 Wfiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx16si1588551ejb.342.2021.03.18.06.35.53; Thu, 18 Mar 2021 06:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbhCRNeX (ORCPT + 99 others); Thu, 18 Mar 2021 09:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhCRNeH (ORCPT ); Thu, 18 Mar 2021 09:34:07 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36555C06174A; Thu, 18 Mar 2021 06:34:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: shreeya) with ESMTPSA id D8B201F45E81 From: Shreeya Patel To: krisman@collabora.com, jaegeuk@kernel.org, yuchao0@huawei.com, tytso@mit.edu, adilger.kernel@dilger.ca, drosen@google.com, ebiggers@google.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel@collabora.com, andre.almeida@collabora.com, Shreeya Patel , kernel test robot Subject: [PATCH v2 3/4] fs: unicode: Use strscpy() instead of strncpy() Date: Thu, 18 Mar 2021 19:03:04 +0530 Message-Id: <20210318133305.316564-4-shreeya.patel@collabora.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210318133305.316564-1-shreeya.patel@collabora.com> References: <20210318133305.316564-1-shreeya.patel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following warning was reported by Kernel Test Robot. In function 'utf8_parse_version', inlined from 'utf8_load' at fs/unicode/utf8mod.c:195:7: >> fs/unicode/utf8mod.c:175:2: warning: 'strncpy' specified bound 12 equals destination size [-Wstringop-truncation] 175 | strncpy(version_string, version, sizeof(version_string)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The -Wstringop-truncation warning highlights the unintended uses of the strncpy function that truncate the terminating NULL character from the source string. Unlike strncpy(), strscpy() always null-terminates the destination string, hence use strscpy() instead of strncpy(). Signed-off-by: Shreeya Patel Reported-by: kernel test robot --- Changes in v2 - Resolve warning of -Wstringop-truncation reported by kernel test robot. fs/unicode/unicode-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/unicode/unicode-core.c b/fs/unicode/unicode-core.c index d5f09e022ac5..287a8a48836c 100644 --- a/fs/unicode/unicode-core.c +++ b/fs/unicode/unicode-core.c @@ -179,7 +179,7 @@ static int unicode_parse_version(const char *version, unsigned int *maj, {0, NULL} }; - strncpy(version_string, version, sizeof(version_string)); + strscpy(version_string, version, sizeof(version_string)); if (match_token(version_string, token, args) != 1) return -EINVAL; -- 2.30.1