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:
@@ -60,7 +60,7 @@ hookup(char *host, int port)
|
||||
int s, len, tos;
|
||||
static char hostnamebuf[80];
|
||||
|
||||
memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
|
||||
memset(&hisctladdr, 0, sizeof (hisctladdr));
|
||||
hisctladdr.sin_addr.s_addr = inet_addr(host);
|
||||
if (hisctladdr.sin_addr.s_addr != INADDR_NONE) {
|
||||
hisctladdr.sin_family = AF_INET;
|
||||
@@ -73,9 +73,9 @@ hookup(char *host, int port)
|
||||
return ((char *) 0);
|
||||
}
|
||||
hisctladdr.sin_family = hp->h_addrtype;
|
||||
memmove((caddr_t)&hisctladdr.sin_addr,
|
||||
hp->h_addr_list[0], hp->h_length);
|
||||
memcpy(&hisctladdr.sin_addr, hp->h_addr, hp->h_length);
|
||||
memmove(&hisctladdr.sin_addr,
|
||||
hp->h_addr_list[0],
|
||||
sizeof(hisctladdr.sin_addr));
|
||||
strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
|
||||
}
|
||||
hostname = hostnamebuf;
|
||||
@@ -95,8 +95,9 @@ hookup(char *host, int port)
|
||||
errno = oerrno;
|
||||
warn("connect to address %s", ia);
|
||||
hp->h_addr_list++;
|
||||
memmove((caddr_t)&hisctladdr.sin_addr,
|
||||
hp->h_addr_list[0], hp->h_length);
|
||||
memmove(&hisctladdr.sin_addr,
|
||||
hp->h_addr_list[0],
|
||||
sizeof(hisctladdr.sin_addr));
|
||||
fprintf(stdout, "Trying %s...\n",
|
||||
inet_ntoa(hisctladdr.sin_addr));
|
||||
close(s);
|
||||
|
@@ -1621,16 +1621,6 @@ renamecmd(char *from, char *to)
|
||||
static void
|
||||
dolog(struct sockaddr_in *sin)
|
||||
{
|
||||
#if 0
|
||||
struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET);
|
||||
|
||||
if (hp)
|
||||
strncpy(remotehost, hp->h_name, sizeof(remotehost));
|
||||
else
|
||||
strncpy(remotehost, inet_ntoa(sin->sin_addr),
|
||||
sizeof(remotehost));
|
||||
#endif
|
||||
inaddr2str (sin->sin_addr, remotehost, sizeof(remotehost));
|
||||
#ifdef HAVE_SETPROCTITLE
|
||||
sprintf(proctitle, "%s: connected", remotehost);
|
||||
|
@@ -150,7 +150,7 @@ get_xsockets (int *unix_socket, int *tcp_socket)
|
||||
|
||||
h = gethostbyname ("localhost");
|
||||
if (h)
|
||||
memcpy (&local, h->h_addr, h->h_length);
|
||||
memcpy (&local, h->h_addr, sizeof(local));
|
||||
else
|
||||
local.s_addr = INADDR_LOOPBACK;
|
||||
|
||||
|
@@ -128,7 +128,7 @@ connect_host (char *host, char *user, des_cblock *key,
|
||||
for(p = hostent->h_addr_list; *p; ++p) {
|
||||
int one = 1;
|
||||
|
||||
memcpy (&thataddr.sin_addr, *p, hostent->h_length);
|
||||
memcpy (&thataddr.sin_addr, *p, sizeof(thataddr.sin_addr));
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
|
@@ -162,7 +162,7 @@ pop_init(POP *p,int argcount,char **argmessage)
|
||||
p->ipport = ntohs(cs.sin_port);
|
||||
|
||||
/* Get the canonical name of the host to whom I am speaking */
|
||||
ch = gethostbyaddr((char *) &cs.sin_addr, sizeof(cs.sin_addr), AF_INET);
|
||||
ch = gethostbyaddr(&cs.sin_addr, sizeof(cs.sin_addr), AF_INET);
|
||||
if (ch == NULL){
|
||||
pop_log(p,POP_PRIORITY,
|
||||
"Unable to get canonical name of client, err = %d",errno);
|
||||
|
@@ -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;
|
||||
|
@@ -68,7 +68,7 @@ inaddr2str(struct in_addr addr, char *s, size_t len)
|
||||
h = gethostbyname (h->h_name);
|
||||
if(h)
|
||||
while ((p = *(h->h_addr_list)++))
|
||||
if (memcmp (p, &addr, h->h_length) == 0) {
|
||||
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
||||
strncpy (s, h->h_name, len);
|
||||
s[len - 1] = '\0';
|
||||
return;
|
||||
|
@@ -100,8 +100,9 @@ __ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser)
|
||||
#define ypdomain NULL
|
||||
#endif
|
||||
/* We need to get the damn hostname back for netgroup matching. */
|
||||
if ((hp = gethostbyaddr((char *)&raddr, sizeof(u_long),
|
||||
AF_INET)) == NULL)
|
||||
if ((hp = gethostbyaddr((char *)&raddr,
|
||||
sizeof(u_long),
|
||||
AF_INET)) == NULL)
|
||||
return (-1);
|
||||
strncpy(hname, hp->h_name, sizeof(hname));
|
||||
hname[sizeof(hname) - 1] = '\0';
|
||||
|
Reference in New Issue
Block a user