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

#define FIX(x) (gr->gr_##x = gr->gr_##x-line+buf)

static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, size_t size, struct group **res)
{
	FILE *f;
	char *line = 0;
	size_t len = 0;
	char **mem = 0;
	size_t nmem = 0;
	int rv = 0;
	size_t i;
	int cs;

	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);

	rv = __getgr_a(name, gid, gr, &line, &len, &mem, &nmem, res);
	if (!rv && size < len + (nmem+1)*sizeof(char *) + 32)
		rv = ERANGE;
	if (!rv) {
		buf += (16-(uintptr_t)buf)%16;
		gr->gr_mem = (void *)buf;
		buf += (nmem+1)*sizeof(char *);
		memcpy(buf, line, len);
		FIX(name);
		FIX(passwd);
		for (i=0; mem[i]; i++)
			gr->gr_mem[i] = mem[i]-line+buf;
		gr->gr_mem[i] = 0;
	}
 	free(mem);
 	free(line);
	fclose(f);
done:
	pthread_setcancelstate(cs, 0);
	return rv;
}

int getgrnam_r(const char *name, struct group *gr, char *buf, size_t size, struct group **res)
{
	return getgr_r(name, 0, gr, buf, size, res);
}

int getgrgid_r(gid_t gid, struct group *gr, char *buf, size_t size, struct group **res)
{
	return getgr_r(0, gid, gr, buf, size, res);
}
debug log:

solving c9b71b7 ...
found c9b71b7 in https://inbox.vuxu.org/musl/1423614776-25579-2-git-send-email-josiahw@gmail.com/
found 3fe2e2b in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 3fe2e2b20b17ca4e182b8707ae68a4d1ebd8918c	src/passwd/getgr_r.c

applying [1/1] https://inbox.vuxu.org/musl/1423614776-25579-2-git-send-email-josiahw@gmail.com/
diff --git a/src/passwd/getgr_r.c b/src/passwd/getgr_r.c
index 3fe2e2b..c9b71b7 100644

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

index at:
100644 c9b71b7ee93052f65e085e0b31569dcc4dabe42f	src/passwd/getgr_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).