summaryrefslogtreecommitdiff
path: root/lib/libc/net/rcmdsh.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-11-24 22:03:34 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-11-24 22:03:34 +0000
commita50c5c6d0278c1f74811d7af263f0a1da4572ef4 (patch)
treed0e56de3e26b5f1fd044285e3c541d6769b1bd32 /lib/libc/net/rcmdsh.c
parentaa7d58417b2629d9f94ae2572e2f74542c3ea214 (diff)
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 'lib/libc/net/rcmdsh.c')
-rw-r--r--lib/libc/net/rcmdsh.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c
index 5d468ff4c44..14275d414a4 100644
--- a/lib/libc/net/rcmdsh.c
+++ b/lib/libc/net/rcmdsh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcmdsh.c,v 1.17 2015/11/01 03:45:29 guenther Exp $ */
+/* $OpenBSD: rcmdsh.c,v 1.18 2015/11/24 22:03:33 millert Exp $ */
/*
* Copyright (c) 2001, MagniComp
@@ -58,15 +58,16 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
struct hostent *hp;
int sp[2];
pid_t cpid;
- char *p;
- struct passwd *pw;
+ char *p, pwbuf[_PW_BUF_LEN];
+ struct passwd pwstore, *pw = NULL;
/* What rsh/shell to use. */
if (rshprog == NULL)
rshprog = _PATH_RSH;
/* locuser must exist on this host. */
- if ((pw = getpwnam(locuser)) == NULL) {
+ getpwnam_r(locuser, &pwstore, pwbuf, sizeof(pwbuf), &pw);
+ if (pw == NULL) {
(void) fprintf(stderr, "rcmdsh: unknown user: %s\n", locuser);
return(-1);
}