diff options
author | ume <ume@FreeBSD.org> | 2000-07-20 18:49:35 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2000-07-20 18:49:35 +0000 |
commit | 54a296ab270d62a4d08ccdf0361fdd6d3a43f7da (patch) | |
tree | b98cb9bbfd6d6e7547a0f4ad883f78c16b4a25a7 /lib/libc | |
parent | 4a9ecb6349180e26273f105c475b5e80a1e15867 (diff) | |
download | FreeBSD-src-54a296ab270d62a4d08ccdf0361fdd6d3a43f7da.zip FreeBSD-src-54a296ab270d62a4d08ccdf0361fdd6d3a43f7da.tar.gz |
Copy canonname for *ahost, into static buffer.
Obtained from: KAME Project
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/rcmd.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 6f076ed..34d6507 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -58,6 +58,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include <rpcsvc/yp_prot.h> #include <rpcsvc/ypclnt.h> #endif +#include <arpa/nameser.h> /* wrapper for KAME-special getnameinfo() */ #ifndef NI_WITHSCOPEID @@ -100,7 +101,8 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) int s, aport, lport, timo, error; char c; int refused; - char num[8], *ohost; + char num[8]; + static char canonnamebuf[MAXDNAME]; /* is it proper here? */ pid = getpid(); @@ -119,8 +121,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) strerror(errno)); return (-1); } - ohost = *ahost; - *ahost = strdup(res->ai_canonname ? res->ai_canonname : *ahost); + + if (res->ai_canonname + && strlen(res->ai_canonname) + 1 < sizeof(canonnamebuf)) { + strncpy(canonnamebuf, res->ai_canonname, sizeof(canonnamebuf)); + *ahost = canonnamebuf; + } ai = res; refused = 0; oldmask = sigblock(sigmask(SIGURG)); @@ -139,8 +145,6 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) strerror(errno)); freeaddrinfo(res); sigsetmask(oldmask); - free(*ahost); - *ahost = ohost; return (-1); } _fcntl(s, F_SETOWN, pid); @@ -187,8 +191,6 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)fprintf(stderr, "%s: %s\n", *ahost, strerror(errno)); freeaddrinfo(res); sigsetmask(oldmask); - free(*ahost); - *ahost = ohost; return (-1); } lport--; @@ -296,8 +298,6 @@ bad: (void)_close(s); sigsetmask(oldmask); freeaddrinfo(res); - free(*ahost); - *ahost = ohost; return (-1); } |