Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9523885ybi; Wed, 24 Jul 2019 05:40:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqybhlM25i2GCXNpbixNDaO3gJ8/VIEQbijyMrWi79NCXQH55c4WNmk0iKIuSisfSV/tlt0g X-Received: by 2002:a17:90a:1904:: with SMTP id 4mr89844924pjg.116.1563972008802; Wed, 24 Jul 2019 05:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563972008; cv=none; d=google.com; s=arc-20160816; b=TDh0nOOdexZsuq8EVZnGE4KkdbWifL9JO1Xh9t4Irn/vj8LdVDRW+fJ/rBgctl4jHR 6Se3xMw7nxaxCsizfed2XQqvyYmcpawRJfdSbPwcxp+F2OvJW9iOdMWcm/wAAp72MMG1 Ym3t6laXYOaxuG8JQedzrfGSQ/ebqFtGADNFAbysKQB7TEjAQvAkjy5UDdmMio6dtJij 3kT01NwPm++dwBB73VSFKuDQZtTS43lbnbOfLH5bt4Jda8H6A/nEH9GBIaBIoeW0bVqN Al6lhkkAHcvMLV+5IecQACm3sp40JqlZxFKG0cIBMcUlr1SjCU9i731ww8kyUGSCHls9 j08Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=TLhZWVwlXn9T3QtJC36QgR+c9FpvulBjIaVLr8QFJ18=; b=lJnxad5mkwXoZGfNoGnFxSUsYiq6upJXcMcr6+w7y9v3mlrv28Ihmvb/5RDlbOZMPm ZTbGgJbV+aI9UJaK0g7pSmEp6VFp1bGanmjKekJ/HbBsMwITsG8PNV7m+lsKHCrtN+yJ wpS0Lt++ApqPiIDNOsJam54YBvR0oyhOSc8wvZczr04TCnqY16yEVwmTPdk5SwkoW3qF iu8e/HI6eyp1FmKLnCSZPUR+BejzhbIzzitckQkW9rx8xJBW6EVNBeaRK6vqnY8KpTbm CsqNSeakM1C/9WBu/nLxG4OW9z6Vy9RKQe2jcZotUSW3IgH32FxThV1O496mHuw1YaK4 GQWQ== 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 a9si15559638pfn.104.2019.07.24.05.39.53; Wed, 24 Jul 2019 05:40:08 -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 S1726764AbfGXKn0 (ORCPT + 99 others); Wed, 24 Jul 2019 06:43:26 -0400 Received: from smtprelay0152.hostedemail.com ([216.40.44.152]:54892 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726070AbfGXKn0 (ORCPT ); Wed, 24 Jul 2019 06:43:26 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 423DB180A68A2; Wed, 24 Jul 2019 10:43:25 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1801:2393:2553:2559:2562:2689:2828:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3867:3868:3871:3872:3874:4321:4605:5007:6119:7576:7903:10004:10394:10400:10848:11026:11232:11233:11473:11658:11914:12043:12049:12297:12438:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21433:21451:21627:21789:30012:30054:30090:30091,0,RBL:23.242.196.136:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: lip98_a3a5877a904 X-Filterd-Recvd-Size: 3083 Received: from XPS-9350 (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA; Wed, 24 Jul 2019 10:43:24 +0000 (UTC) Message-ID: Subject: Re: [Fwd: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms] From: Joe Perches To: David Laight , Julia Lawall Cc: cocci , LKML Date: Wed, 24 Jul 2019 03:43:22 -0700 In-Reply-To: <563222fbfdbb44daa98078db9d404972@AcuMS.aculab.com> References: <7ab8957eaf9b0931a59eff6e2bd8c5169f2f6c41.1563841972.git.joe@perches.com> <66fcdbf607d7d0bea41edb39e5579d63b62b7d84.camel@perches.com> <0f3ba090dfc956f5651e6c7c430abdba94ddcb8b.camel@perches.com> <563222fbfdbb44daa98078db9d404972@AcuMS.aculab.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-07-24 at 10:28 +0000, David Laight wrote: > From: Joe Perches > > Sent: 24 July 2019 05:38 > > On Tue, 2019-07-23 at 23:27 -0500, Julia Lawall wrote: > > > On Tue, 23 Jul 2019, Joe Perches wrote: > > > > On Tue, 2019-07-23 at 22:54 -0500, Julia Lawall wrote: > > > > > A seantic patch and the resulting output for the case where the third > > > > > arugument is a constant is attached. Likewise the resulting output on a > > > > > recent linux-next. [] > > > > There is a problem with conversions with assignments > > > > of strlcpy() so ideally the cocci script should make sure > > > > any return value was not used before conversion. > > > > > > > > This is not a provably good conversion: > > > > > > > > drivers/s390/char/sclp_ftp.c > > > > @@ -114,8 +114,7 @@ static int sclp_ftp_et7(const struct hmc > > > > sccb->evbuf.mdd.ftp.length = ftp->len; > > > > sccb->evbuf.mdd.ftp.bufaddr = virt_to_phys(ftp->buf); > > > > > > > > - len = strlcpy(sccb->evbuf.mdd.ftp.fident, ftp->fname, > > > > - HMCDRV_FTP_FIDENT_MAX); > > > > + len = stracpy(sccb->evbuf.mdd.ftp.fident, ftp->fname); [] > > Any use of the strlcpy return value should not be converted > > because the logic after an assignment or use of the return value > > can not be assured to have the same behavior. > > Most of the code probably expects the length to be that copied > (so is broken if the string is truncated). Fortunately there are relatively few uses of the return value of strlcpy so it's not a large problem set. Slightly unrepresentative counts: $ git grep -P "^\s+strlcpy\b" | wc -l 1681 $ git grep -P "=\s*strlcpy\b" | wc -l 28