mailing list of musl libc
 help / color / mirror / code / Atom feed
1db10db2d61062e105e7cf000354103801b8fc10 blob 878 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
 
#include "pwf.h"
#include <pthread.h>

#define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf)

static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res)
{
	FILE *f;
	char *line = 0;
	size_t len = 0;
	int rv = 0;
	int cs;

	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);

	rv = __getpw_a(name, uid, pw, &line, &len, res);
	if (!rv && size < len)
		rv = ERANGE;
	if (!rv) {
		memcpy(buf, line, len);
		FIX(name);
		FIX(passwd);
		FIX(gecos);
		FIX(dir);
		FIX(shell);
	}
 	free(line);
done:
	pthread_setcancelstate(cs, 0);
	return rv;
}

int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, struct passwd **res)
{
	return getpw_r(name, 0, pw, buf, size, res);
}

int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res)
{
	return getpw_r(0, uid, pw, buf, size, res);
}
debug log:

solving 1db10db ...
found 1db10db in https://inbox.vuxu.org/musl/1423614776-25579-1-git-send-email-josiahw@gmail.com/
found 2855257 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 285525727dc74647e56726f2f894956d00776fa0	src/passwd/getpw_r.c

applying [1/1] https://inbox.vuxu.org/musl/1423614776-25579-1-git-send-email-josiahw@gmail.com/
diff --git a/src/passwd/getpw_r.c b/src/passwd/getpw_r.c
index 2855257..1db10db 100644

Checking patch src/passwd/getpw_r.c...
Applied patch src/passwd/getpw_r.c cleanly.

index at:
100644 1db10db2d61062e105e7cf000354103801b8fc10	src/passwd/getpw_r.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).