diff options
author | millert <> | 2015-11-24 22:03:33 +0000 |
---|---|---|
committer | millert <> | 2015-11-24 22:03:33 +0000 |
commit | d0a2512c90ba0643904f25de1b66ccfc86502617 (patch) | |
tree | 2ff05b2b872a27106976e6dd366bcbc261b1d2eb /src/lib/libc/net/ruserok.c | |
parent | 538f104d39a36dc15e460dc8b641f8f410d06b85 (diff) | |
download | openbsd-d0a2512c90ba0643904f25de1b66ccfc86502617.tar.gz openbsd-d0a2512c90ba0643904f25de1b66ccfc86502617.tar.bz2 openbsd-d0a2512c90ba0643904f25de1b66ccfc86502617.zip |
Use reentrant versions of getpw{nam,uid} and getgr{nam,gid} within
libc to avoid reusing the static buffers returned by the non-reentrant
versions. Since this is inside libc we can use constants for the
buffer sizes instead of having to call sysconf().
OK guenther@ deraadt@
Diffstat (limited to 'src/lib/libc/net/ruserok.c')
-rw-r--r-- | src/lib/libc/net/ruserok.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/net/ruserok.c b/src/lib/libc/net/ruserok.c index 88c89ac40f..7dda9550a8 100644 --- a/src/lib/libc/net/ruserok.c +++ b/src/lib/libc/net/ruserok.c | |||
@@ -111,11 +111,11 @@ iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser, | |||
111 | struct sockaddr *sa; | 111 | struct sockaddr *sa; |
112 | char *cp; | 112 | char *cp; |
113 | struct stat sbuf; | 113 | struct stat sbuf; |
114 | struct passwd *pwd; | 114 | struct passwd pwstore, *pwd; |
115 | FILE *hostf; | 115 | FILE *hostf; |
116 | uid_t uid; | 116 | uid_t uid; |
117 | int first; | 117 | int first; |
118 | char pbuf[PATH_MAX]; | 118 | char pbuf[PATH_MAX], pwbuf[_PW_BUF_LEN]; |
119 | 119 | ||
120 | sa = (struct sockaddr *)raddr; | 120 | sa = (struct sockaddr *)raddr; |
121 | first = 1; | 121 | first = 1; |
@@ -132,7 +132,9 @@ again: | |||
132 | int len; | 132 | int len; |
133 | 133 | ||
134 | first = 0; | 134 | first = 0; |
135 | if ((pwd = getpwnam(luser)) == NULL) | 135 | pwd = NULL; |
136 | getpwnam_r(luser, &pwstore, pwbuf, sizeof(pwbuf), &pwd); | ||
137 | if (pwd == NULL) | ||
136 | return (-1); | 138 | return (-1); |
137 | len = snprintf(pbuf, sizeof pbuf, "%s/.rhosts", pwd->pw_dir); | 139 | len = snprintf(pbuf, sizeof pbuf, "%s/.rhosts", pwd->pw_dir); |
138 | if (len < 0 || len >= sizeof pbuf) | 140 | if (len < 0 || len >= sizeof pbuf) |