Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4102906ybi; Mon, 27 May 2019 11:10:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpbrJ7j11ZzYMgWmrTBDkvPDK+OIXD8JToFQWzZ7LtXJCY09su9jDf34IFkJ5kBOH4MJgh X-Received: by 2002:a63:2844:: with SMTP id o65mr41463372pgo.297.1558980606590; Mon, 27 May 2019 11:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558980606; cv=none; d=google.com; s=arc-20160816; b=XUlh81W4sP4MXlO9uKp1XB5oD39ZjpB+SpG7iEU8QaNl99BUengOXPrisew1mT3jSz W/oab239qHrCrNtem2oOjArGY/OBhNFaFQeXJ8pVEAFQwM5vHCxKCIFP7eHrIGpy2fUu 2SAIk3yyfkgrgUNPoNSotD4nRCfd8ObYnJ/zZKti5jRrQz3rbR/sAwbA+TajdJgA3SV5 A6gsCgAbgfiKMHxqCuXNqNNKdjJ+iF5OG2vTp3Lrlv45jmS3jiiVmrRyl86aKOm11i9l Vg5gf5vgZ+LEsN4E9G4fC5RmJt6TpoOxsY3rj3QT9eo0zvXbNiMpzfhDwle/dHJ3Ucgd YwCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=iOUjdLMhIeH1LHhKBAbsUS1F2Buf+fUIGDr0wuv4On8=; b=hq72/4UNvqOPAvfwwWu3qlddnComQ+/+i6O35kApsvbG3HNrwLCrYAJYkbLNCz4yFi E0pkfaHCYZhRRxOlt1WoGzXR4wcIUhYSNPwUCGhlxCKJb8O2MG66lgLKTGKkKFRg3tVw Uod20UYeYO4FOO9TMvcqpdmhpkKWG+C0wn/UlpZWHXmdye+rIgvKUdw40U6CWZzJy1WY YfbDR1s4MvNUtC+SSIW1kc3c/0L+w+oosV1cT6h78NwhnzBatQBuBIMj2g3va6ANjZiG x9FVqxUPzmLItQj3zQW8skQlAt/BvWybqnW5HrvlOZr5XSiQB/Zy8QR2retAsb8sFW/7 jktA== 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 c94si147047pje.24.2019.05.27.11.09.50; Mon, 27 May 2019 11:10:06 -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 S1727289AbfE0SIB (ORCPT + 99 others); Mon, 27 May 2019 14:08:01 -0400 Received: from gateway36.websitewelcome.com ([192.185.179.26]:35452 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbfE0SIB (ORCPT ); Mon, 27 May 2019 14:08:01 -0400 X-Greylist: delayed 1224 seconds by postgrey-1.27 at vger.kernel.org; Mon, 27 May 2019 14:08:00 EDT Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 69E0740169CE6 for ; Mon, 27 May 2019 12:07:56 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id VJihhWBMZ90onVJihhZbJD; Mon, 27 May 2019 12:47:35 -0500 X-Authority-Reason: nr=8 Received: from [189.250.47.159] (port=36866 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1hVJig-002gpt-Nl; Mon, 27 May 2019 12:47:34 -0500 Date: Mon, 27 May 2019 12:47:33 -0500 From: "Gustavo A. R. Silva" To: Gabriel Krisman Bertazi Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] unicode: replace strncpy() by strscpy() Message-ID: <20190527174733.GA29547@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.47.159 X-Source-L: No X-Exim-ID: 1hVJig-002gpt-Nl X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.47.159]:36866 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The strncpy() function is being deprecated. Replace it by the safer strscpy() and fix the following Coverity warning: "Calling strncpy with a maximum size argument of 12 bytes on destination array version_string of size 12 bytes might leave the destination string unterminated." Notice that, unlike strncpy(), strscpy() always null-terminates the destination string. Addresses-Coverity-ID: 1445547 ("Buffer not null terminated") Signed-off-by: Gustavo A. R. Silva --- fs/unicode/utf8-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 6afab4fdce90..a367041468cf 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -131,7 +131,7 @@ static int utf8_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.21.0