Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190326093648.5669-1-fziglio@redhat.com>
Date: Tue, 26 Mar 2019 09:36:47 +0000
From: Frediano Ziglio <fziglio@...hat.com>
To: musl@...ts.openwall.com
Cc: Frediano Ziglio <fziglio@...hat.com>
Subject: [PATCH 1/2] use __strchrnul instead of strchr and strlen

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;
-- 
2.20.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.