diff options
| author | millert <> | 2015-11-24 22:03:33 +0000 |
|---|---|---|
| committer | millert <> | 2015-11-24 22:03:33 +0000 |
| commit | 7b803d1733f95d2823783aaaeb057de2eaab0231 (patch) | |
| tree | 2ff05b2b872a27106976e6dd366bcbc261b1d2eb /src/lib/libc/net/ruserok.c | |
| parent | 0dbd386e3a1720959cdaa0731b8feb9c2c5b62dd (diff) | |
| download | openbsd-7b803d1733f95d2823783aaaeb057de2eaab0231.tar.gz openbsd-7b803d1733f95d2823783aaaeb057de2eaab0231.tar.bz2 openbsd-7b803d1733f95d2823783aaaeb057de2eaab0231.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 '')
| -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) |
