mailing list of musl libc
 help / color / mirror / code / Atom feed
5c486b15f317289bc1cc5c49ca05c1e02a8fd2d9 blob 982 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>

extern char **__environ;

int __execvpe(const char *file, char *const argv[], char *const envp[])
{
	const char *p, *z, *path = getenv("PATH");
	size_t l, k;

	errno = ENOENT;
	if (!*file) return -1;

	if (strchr(file, '/'))
		return execve(file, argv, envp);

	if (!path) path = "/usr/local/bin:/bin:/usr/bin";
	k = strnlen(file, NAME_MAX+1);
	if (k > NAME_MAX) {
		errno = ENAMETOOLONG;
		return -1;
	}
	l = strnlen(path, PATH_MAX-1)+1;

	for(p=path; ; p=z) {
		char b[l+k+1];
		z = strchr(p, ':');
		if (!z) z = p+strlen(p);
		if (z-p >= l) {
			if (!*z++) break;
			continue;
		}
		memcpy(b, p, z-p);
		b[z-p] = '/';
		memcpy(b+(z-p)+(z>p), file, k+1);
		execve(b, argv, envp);
		if (errno != ENOENT) return -1;
		if (!*z++) break;
	}
	return -1;
}

int execvp(const char *file, char *const argv[])
{
	return __execvpe(file, argv, __environ);
}

weak_alias(__execvpe, execvpe);
debug log:

solving 5c486b1 ...
found 5c486b1 in https://inbox.vuxu.org/musl/CAL3m8eBQWY-dbxy1M97HSmDcWBB3Vu7cztQ1fd3KNUqchyiZ=Q@mail.gmail.com/
found 0a33e42 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 0a33e42db9a66fb52ef04cd05230dc5b83fe7d11	src/process/execvp.c

applying [1/1] https://inbox.vuxu.org/musl/CAL3m8eBQWY-dbxy1M97HSmDcWBB3Vu7cztQ1fd3KNUqchyiZ=Q@mail.gmail.com/
diff --git a/src/process/execvp.c b/src/process/execvp.c
index 0a33e42..5c486b1 100644

Checking patch src/process/execvp.c...
Applied patch src/process/execvp.c cleanly.

index at:
100644 5c486b15f317289bc1cc5c49ca05c1e02a8fd2d9	src/process/execvp.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).