Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp185379ybl; Tue, 20 Aug 2019 18:01:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqydVgac0pOo5DXC30GMFxF0Qf4yoVIJi5Kw1Ke3aqLLm586uSY/0QPjun8/aCWpvnkoLIi3 X-Received: by 2002:a17:90a:36ad:: with SMTP id t42mr2728738pjb.21.1566349301356; Tue, 20 Aug 2019 18:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566349301; cv=none; d=google.com; s=arc-20160816; b=P3/nw/X60O8U1UmzZ9b2WAx8aCEfPxtY6wsX/eZP6X+2O3tEWk1S2tXh7m7Q6k4PqS x9YbEstKKfZbYpvshVTTYwe37RBQaUb91NPxahDtspq/i9ncVCj6XVz5VY7lsqotT1Te Q4z++e5KRbQknrPWHpvZCGQ87vy9f318OG3wmxrizXPJoyHVjLYVyuzSBJMdPmsAhF2R jStN++sDnUtNo/uI02s6f22ec1VsSE89WNyl9v/bvUbPiUqTresLGhL2L4YVZavQKoS8 mdxby8tskPlFLN9ssBkZ73yZTCl6OK4i4SPKpky+OKPU2AR/TC/Pj8193lrCiChprYWf w5Sw== 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=pg6PaYTCBX2LYGOr5ib5E0xALWl6uALgbv+MwFyG49E=; b=IpMhSF3jAq7g4Z5CsY1d5aDcfi2G5yVEoNVkfKUlHxHBOIG7XfmEVRk49r62fD9sQj Xe/8asmwutI0va/pP/HW7ZwoT0WhFcrhZzmounpzLGgH00lfLOH0VFjS5CdgZk2VuDgO xj+gptqaqdrWN69/ifL6JQnvrYKuXP0jHutkwGe8J0KghAlMxR696lStw4iIV6MCIlKc KpvsHethiXOiY1WRCMVXZYI+vc3sK4GpMCSPvekghPI4fnW1DpXJWvrV8ixnjlepN8yI Qh9eg4bk3K5ifnE9FSo7T2R+CrvH+6vMyI/0c5YH8vFbrLTvwooe49DbYjEY74mFGjIL IKvQ== 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 y12si13028669pfo.30.2019.08.20.18.01.25; Tue, 20 Aug 2019 18:01: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 S1726546AbfHUA6c (ORCPT + 99 others); Tue, 20 Aug 2019 20:58:32 -0400 Received: from smtprelay0112.hostedemail.com ([216.40.44.112]:60035 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726202AbfHUA6b (ORCPT ); Tue, 20 Aug 2019 20:58:31 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id F224E18011250; Wed, 21 Aug 2019 00:58:29 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 10,1,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1963:2198:2199:2393:2553:2559:2562:2828:2840:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4043:4250:4321:5007:6691:8603:10004:10400:10848:11232:11658:11914:12296:12297:12679:12740:12760:12895:13019:13069:13161:13229:13311:13357:13439:14096:14097:14181:14659:14721:21067:21080:21433:21627:21786:21796:21944:30036:30054:30060:30070:30079: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:1:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: month89_fcc67fbeb43c X-Filterd-Recvd-Size: 3518 Received: from XPS-9350.home (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA; Wed, 21 Aug 2019 00:58:28 +0000 (UTC) Message-ID: Subject: stracpy From: Joe Perches To: Linus Torvalds Cc: Stephen Rothwell , Julia Lawall , "Gustavo A. R. Silva" , LKML , clang-built-linux@googlegroups.com, Linux Next Mailing List Date: Tue, 20 Aug 2019 17:58:27 -0700 In-Reply-To: References: <9c7a79b4d21aea52464d00c8fa4e4b92638560b6.camel@perches.com> <6a5f470c1375289908c37632572c4aa60d6486fa.camel@perches.com> <4398924f28a58fca296d101dae11e7accce80656.camel@perches.com> <20190820092451.791c85e5@canb.auug.org.au> <14723fccc2c3362cc045df17fc8554f37c8a8529.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.32.1-2 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 Tue, 2019-08-20 at 17:43 -0700, Linus Torvalds wrote: > On Tue, Aug 20, 2019 at 5:20 PM Joe Perches wrote: > > Umm, btw: have you actually looked at stracpy? > > Yes, Joe, I have. > > What part of "there are now so many of them that no human being can > keep track of them" didn't you see as a problem? Well, the actual post-conversion uses to stracpy make the old ones (strcpy/strlcpy/strncpy) exceptional uses that can be analyzed quite a bit more easily. btw: I really don't care what any convenience macro is named. Most all of the strlcpy and strscpy uses actually _do_ copy to a char array and strscpy is a simple interface that is somewhat frequently misused. > How many broken string functions are we going to do, adding yet > another one when you notice that the _last_ one wasn't great? > > We never seem to remove the broken ones. We just add yet another one, > and have a never-ending jumble of random letters. Intermediate problems. > I would seriously suggest doing something like > and > copy_string( dst, dstsize, src, srcsize, FLAGS ); > > where FLAGS migth be "pad" or whatever. Make it return the size of the > resulting string, because while it can be convenient to pass 'dst" on, > it's not useful. That's simply not convenient for pointers. Auditing the kernel for those unsized uses is a large scope problem. Even anything that uses PAGE_SIZE sized allocations does sprintf instead of snprintf. Any show_ for instance. > And then maybe just add the helper macro that turns an array into a > "pointer, size" combination, rather than yet another letter jumble. Good luck with that when an unsized char pointer is the thing passed to a function. There are _way_ too many of those already in the kernel. Simple strcpy is already used > 2000 times.