diff options
| author | Bill Paul <wpaul@FreeBSD.org> | 1996-03-16 21:25:59 +0000 |
|---|---|---|
| committer | Bill Paul <wpaul@FreeBSD.org> | 1996-03-16 21:25:59 +0000 |
| commit | 6daf17201be2ab73b696b6c3e98398c418517d5f (patch) | |
| tree | ead06bf99b092dc1b18f2a136c2e3b468c20cbda /lib/libc/net/gethostbynis.c | |
| parent | 8f2ec877b86a36587e164f4b8b55c90d4e4754d1 (diff) | |
Notes
Diffstat (limited to 'lib/libc/net/gethostbynis.c')
| -rw-r--r-- | lib/libc/net/gethostbynis.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c index 53b426d19a21..f01f1052f36e 100644 --- a/lib/libc/net/gethostbynis.c +++ b/lib/libc/net/gethostbynis.c @@ -24,8 +24,8 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)$Id$"; -static char rcsid[] = "$Id$"; +static char sccsid[] = "@(#)$Id: gethostbynis.c,v 1.1 1994/09/25 02:12:14 pst Exp $"; +static char rcsid[] = "$Id: gethostbynis.c,v 1.1 1994/09/25 02:12:14 pst Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -37,6 +37,11 @@ static char rcsid[] = "$Id$"; #include <ctype.h> #include <errno.h> #include <string.h> +#ifdef YP +#include <rpc/rpc.h> +#include <rpcsvc/yp_prot.h> +#include <rpcsvc/ypclnt.h> +#endif #define MAXALIASES 35 #define MAXADDRS 35 @@ -57,6 +62,7 @@ _gethostbynis(name, map) int resultlen; static struct hostent h; static char *domain = (char *)NULL; + static char ypbuf[YPMAXRECORD]; if (domain == (char *)NULL) if (yp_get_default_domain (&domain)) @@ -65,6 +71,11 @@ _gethostbynis(name, map) if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) return ((struct hostent *)NULL); + /* avoid potential memory leak */ + bcopy((char *)result, (char *)&ypbuf, resultlen); + free(result); + result = (char *)&ypbuf; + if ((cp = index(result, '\n'))) *cp = '\0'; @@ -108,8 +119,10 @@ _gethostbynisname(name) } struct hostent * -_gethostbynisaddr(name) - char *name; +_gethostbynisaddr(addr, len, type) + char *addr; + int len; + int type; { - return _gethostbynis(name, "hosts.byaddr"); + return _gethostbynis(inet_ntoa(*(struct in_addr *)addr),"hosts.byaddr"); } |
