use __strchrnul instead of strchr and strlen in execvpe
authorFrediano Ziglio <fziglio@redhat.com>
Tue, 26 Mar 2019 09:36:47 +0000 (09:36 +0000)
committerRich Felker <dalias@aerifal.cx>
Tue, 2 Apr 2019 14:40:01 +0000 (10:40 -0400)
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

index 1fdf036fde5f72550f2d5b247096d358c5f9b156..ef3b9dd598fc57ab8f257c4043c9f00c62000234 100644 (file)
@@ -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;