diff options
author | imp <imp@FreeBSD.org> | 1998-06-09 04:31:02 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1998-06-09 04:31:02 +0000 |
commit | 8c96be00ef748f03f9e7f9f5934e7b0d53d1c872 (patch) | |
tree | 4cac82b29697cfe595adc937f0a97621ae134760 /usr.bin/telnet | |
parent | 9a6732bd4e65d3bdaeb59e6b7cd0331484e1c331 (diff) | |
download | FreeBSD-src-8c96be00ef748f03f9e7f9f5934e7b0d53d1c872.zip FreeBSD-src-8c96be00ef748f03f9e7f9f5934e7b0d53d1c872.tar.gz |
Don't assume that hp->h_lenght == 4. Be conservative in its use.
Submitted by: J. Assange a long time ago.
Diffstat (limited to 'usr.bin/telnet')
-rw-r--r-- | usr.bin/telnet/commands.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 0d190cb..c3e1f87 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -2201,9 +2201,11 @@ tn(argc, argv) 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); + host->h_addr_list[0], + MIN(host->h_length, sizeof(sin.sin_addr))); #else /* defined(h_addr) */ - memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); + memmove((caddr_t)&sin.sin_addr, host->h_addr, + MIN(host->h_length, sizeof(sin.sin_addr))); #endif /* defined(h_addr) */ strncpy(_hostname, host->h_name, sizeof(_hostname)); _hostname[sizeof(_hostname)-1] = '\0'; @@ -2294,8 +2296,8 @@ tn(argc, argv) errno = oerrno; perror((char *)0); host->h_addr_list++; - memcpy((caddr_t)&sin.sin_addr, - host->h_addr_list[0], host->h_length); + memcpy((caddr_t)&sin.sin_addr, host->h_addr_list[0], + MIN(host->h_length, sizeof(sin.sin_addr))); (void) NetClose(net); continue; } @@ -2779,10 +2781,11 @@ sourceroute(arg, cpp, lenp) sin_addr.s_addr = tmp; } else if (host = gethostbyname(cp)) { #if defined(h_addr) - memcpy((caddr_t)&sin_addr, - host->h_addr_list[0], host->h_length); + memcpy((caddr_t)&sin_addr, host->h_addr_list[0], + MIN(host->h_length,sizeof(sin_addr))); #else - memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length); + memcpy((caddr_t)&sin_addr, host->h_addr, + MIN(host->h_length,sizeof(sin_addr))); #endif } else { *cpp = cp; |