Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: fusl/src/passwd/getpw_r.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/passwd/getpw_a.c ('k') | fusl/src/passwd/getpwent.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "pwf.h"
2 #include <pthread.h>
3
4 #define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf)
5
6 static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si ze_t size, struct passwd **res)
7 {
8 char *line = 0;
9 size_t len = 0;
10 int rv = 0;
11 int cs;
12
13 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
14
15 rv = __getpw_a(name, uid, pw, &line, &len, res);
16 if (*res && size < len) {
17 *res = 0;
18 rv = ERANGE;
19 }
20 if (*res) {
21 memcpy(buf, line, len);
22 FIX(name);
23 FIX(passwd);
24 FIX(gecos);
25 FIX(dir);
26 FIX(shell);
27 }
28 free(line);
29 pthread_setcancelstate(cs, 0);
30 return rv;
31 }
32
33 int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, stru ct passwd **res)
34 {
35 return getpw_r(name, 0, pw, buf, size, res);
36 }
37
38 int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct pass wd **res)
39 {
40 return getpw_r(0, uid, pw, buf, size, res);
41 }
OLDNEW
« no previous file with comments | « fusl/src/passwd/getpw_a.c ('k') | fusl/src/passwd/getpwent.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698