From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14042 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Frediano Ziglio Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 1/2] use __strchrnul instead of strchr and strlen Date: Tue, 2 Apr 2019 05:57:33 -0400 (EDT) Message-ID: <1508751505.10584787.1554199053330.JavaMail.zimbra@redhat.com> References: <20190326093648.5669-1-fziglio@redhat.com> 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="219338"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-14058-gllmg-musl=m.gmane.org@lists.openwall.com Tue Apr 02 11:57:50 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 1hBGAw-000uxw-2Q for gllmg-musl@m.gmane.org; Tue, 02 Apr 2019 11:57:50 +0200 Original-Received: (qmail 5250 invoked by uid 550); 2 Apr 2019 09:57:46 -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 5227 invoked from network); 2 Apr 2019 09:57:45 -0000 In-Reply-To: <20190326093648.5669-1-fziglio@redhat.com> X-Originating-IP: [10.33.32.21, 10.4.195.18] Thread-Topic: use __strchrnul instead of strchr and strlen Thread-Index: 2ix1plRMnq/+IQr84Vc98aodKWZQGA== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 02 Apr 2019 09:57:33 +0000 (UTC) Xref: news.gmane.org gmane.linux.lib.musl.general:14042 Archived-At: ping > > The result is the same but takes less code. > Note that __execvpe calls getenv which calls __strchrnul so even > using static output the size of the executable won't grow. > --- > src/process/execvp.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/src/process/execvp.c b/src/process/execvp.c > index 1fdf036f..ef3b9dd5 100644 > --- a/src/process/execvp.c > +++ b/src/process/execvp.c > @@ -28,8 +28,7 @@ int __execvpe(const char *file, char *const argv[], char > *const envp[]) > > for(p=path; ; p=z) { > char b[l+k+1]; > - z = strchr(p, ':'); > - if (!z) z = p+strlen(p); > + z = __strchrnul(p, ':'); > if (z-p >= l) { > if (!*z++) break; > continue;