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/rcmdsh.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/rcmdsh.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libc/net/rcmdsh.c b/src/lib/libc/net/rcmdsh.c index 5d468ff4c4..14275d414a 100644 --- a/src/lib/libc/net/rcmdsh.c +++ b/src/lib/libc/net/rcmdsh.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rcmdsh.c,v 1.17 2015/11/01 03:45:29 guenther Exp $ */ | 1 | /* $OpenBSD: rcmdsh.c,v 1.18 2015/11/24 22:03:33 millert Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2001, MagniComp | 4 | * Copyright (c) 2001, MagniComp |
| @@ -58,15 +58,16 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, | |||
| 58 | struct hostent *hp; | 58 | struct hostent *hp; |
| 59 | int sp[2]; | 59 | int sp[2]; |
| 60 | pid_t cpid; | 60 | pid_t cpid; |
| 61 | char *p; | 61 | char *p, pwbuf[_PW_BUF_LEN]; |
| 62 | struct passwd *pw; | 62 | struct passwd pwstore, *pw = NULL; |
| 63 | 63 | ||
| 64 | /* What rsh/shell to use. */ | 64 | /* What rsh/shell to use. */ |
| 65 | if (rshprog == NULL) | 65 | if (rshprog == NULL) |
| 66 | rshprog = _PATH_RSH; | 66 | rshprog = _PATH_RSH; |
| 67 | 67 | ||
| 68 | /* locuser must exist on this host. */ | 68 | /* locuser must exist on this host. */ |
| 69 | if ((pw = getpwnam(locuser)) == NULL) { | 69 | getpwnam_r(locuser, &pwstore, pwbuf, sizeof(pwbuf), &pw); |
| 70 | if (pw == NULL) { | ||
| 70 | (void) fprintf(stderr, "rcmdsh: unknown user: %s\n", locuser); | 71 | (void) fprintf(stderr, "rcmdsh: unknown user: %s\n", locuser); |
| 71 | return(-1); | 72 | return(-1); |
| 72 | } | 73 | } |
