From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14018 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Frediano Ziglio Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 2/2] avoid passing a parameter Date: Tue, 26 Mar 2019 11:22:05 -0400 (EDT) Message-ID: <811064381.9744980.1553613725891.JavaMail.zimbra@redhat.com> References: <20190326093648.5669-1-fziglio@redhat.com> <20190326093648.5669-2-fziglio@redhat.com> <20190326150727.GZ23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="185096"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-14034-gllmg-musl=m.gmane.org@lists.openwall.com Tue Mar 26 16:22:21 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1h8nu9-000m01-91 for gllmg-musl@m.gmane.org; Tue, 26 Mar 2019 16:22:21 +0100 Original-Received: (qmail 22072 invoked by uid 550); 26 Mar 2019 15:22:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 22049 invoked from network); 26 Mar 2019 15:22:17 -0000 In-Reply-To: <20190326150727.GZ23599@brightrain.aerifal.cx> X-Originating-IP: [10.33.32.13, 10.4.195.11] Thread-Topic: avoid passing a parameter Thread-Index: erEnjgKxdZ4zf/Bjl63VXALbtKJC0A== X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 26 Mar 2019 15:22:06 +0000 (UTC) Xref: news.gmane.org gmane.linux.lib.musl.general:14018 Archived-At: > On Tue, Mar 26, 2019 at 09:36:48AM +0000, Frediano Ziglio wrote: > > Make code slightly smaller. > > "file" should not be long and it should fit in NAME_MAX so > > this code would be faster only rarely. > > --- > > src/process/execvp.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/process/execvp.c b/src/process/execvp.c > > index ef3b9dd5..a2726af9 100644 > > --- a/src/process/execvp.c > > +++ b/src/process/execvp.c > > @@ -19,7 +19,7 @@ int __execvpe(const char *file, char *const argv[], char > > *const envp[]) > > return execve(file, argv, envp); > > > > if (!path) path = "/usr/local/bin:/bin:/usr/bin"; > > - k = strnlen(file, NAME_MAX+1); > > + k = strlen(file); > > if (k > NAME_MAX) { > > errno = ENAMETOOLONG; > > return -1; > > -- > > 2.20.1 > > Patch 1 looks ok, but patch 2 here is contrary to the direction I want > to take things in musl. Using strnlen everywhere that excess length is > an error is an idiom I'm trying to adopt all over. Here there's no > serious practical impact either way (size difference is tiny, input > string is not untrusted), but I still prefer use of the idiom. > > Rich > Fine for me to drop 2/2, I reached this code trying to workaround a bug in binutils (I have a Fedora 29 with binutils 2.31 where each static executable produced by musl were crashing). Why not updating https://wiki.musl-libc.org/coding-style.html ? Frediano