careful not to thrust h_length from gethostby{name,addr}

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1056 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-11-19 21:56:12 +00:00
parent 42ba7456be
commit 99f492acf0
8 changed files with 26 additions and 30 deletions

View File

@@ -2255,10 +2255,11 @@ int tn(int argc, char **argv)
if (host) {
sin.sin_family = host->h_addrtype;
#if defined(h_addr) /* In 4.3, this is a #define */
memmove((caddr_t)&sin.sin_addr,
host->h_addr_list[0], host->h_length);
memmove(&sin.sin_addr,
host->h_addr_list[0],
sizeof(sin.sin_addr));
#else /* defined(h_addr) */
memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
memmove(&sin.sin_addr, host->h_addr, sizeof(sin.sin_addr));
#endif /* defined(h_addr) */
strncpy(_hostname, host->h_name, sizeof(_hostname));
_hostname[sizeof(_hostname)-1] = '\0';
@@ -2351,8 +2352,9 @@ int tn(int argc, char **argv)
errno = oerrno;
perror((char *)0);
host->h_addr_list++;
memmove((caddr_t)&sin.sin_addr,
host->h_addr_list[0], host->h_length);
memmove(&sin.sin_addr,
host->h_addr_list[0],
sizeof(sin.sin_addr));
NetClose(net);
continue;
}
@@ -2718,10 +2720,12 @@ sourceroute(arg, cpp, lenp)
sin_addr.s_addr = tmp;
} else if (host = gethostbyname(cp)) {
#if defined(h_addr)
memmove((caddr_t)&sin_addr,
host->h_addr_list[0], host->h_length);
memmove(&sin_addr,
host->h_addr_list[0],
sizeof(sin_addr));
#else
memmove((caddr_t)&sin_addr, host->h_addr, host->h_length);
memmove(&sin_addr, host->h_addr,
sizeof(sin_addr));
#endif
} else {
*cpp = cp;