From a50c5c6d0278c1f74811d7af263f0a1da4572ef4 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 24 Nov 2015 22:03:34 +0000 Subject: 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@ --- lib/libc/net/rcmdsh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/libc/net/rcmdsh.c') 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); } -- cgit v1.2.3