View | Details | Raw Unified | Return to bug 2586
Collapse All | Expand All

(-)src/usr.sbin/syslogd/syslogd.c (-1 / +1 lines)
Lines 1155-1161 Link Here
1155
			 sizeof(f->f_un.f_forw.f_addr));
1155
			 sizeof(f->f_un.f_forw.f_addr));
1156
		f->f_un.f_forw.f_addr.sin_family = AF_INET;
1156
		f->f_un.f_forw.f_addr.sin_family = AF_INET;
1157
		f->f_un.f_forw.f_addr.sin_port = LogPort;
1157
		f->f_un.f_forw.f_addr.sin_port = LogPort;
1158
		memmove(&f->f_un.f_forw.f_addr.sin_addr, hp->h_addr, hp->h_length);
1158
		memmove(&f->f_un.f_forw.f_addr.sin_addr, hp->h_addr, MIN(hp->h_length,sizeof(struct in_addr));
1159
		f->f_type = F_FORW;
1159
		f->f_type = F_FORW;
1160
		break;
1160
		break;
1161
1161
(-)src/usr.sbin/ppp/ipcp.c (-1 / +1 lines)
Lines 151-157 Link Here
151
  if (gethostname(name, sizeof(name)) == 0) {
151
  if (gethostname(name, sizeof(name)) == 0) {
152
      hp = gethostbyname(name);
152
      hp = gethostbyname(name);
153
      if (hp && hp->h_addrtype == AF_INET) {
153
      if (hp && hp->h_addrtype == AF_INET) {
154
	bcopy(hp->h_addr, (char *)&DefMyAddress.ipaddr.s_addr, hp->h_length);
154
	bcopy(hp->h_addr, (char *)&DefMyAddress.ipaddr.s_addr, MIN(hp->h_length, sizeof DefMyAddress.ipaddr.s_addr));
155
      }
155
      }
156
  }
156
  }
157
}
157
}
(-)src/usr.sbin/ppp/command.c (-1 / +1 lines)
Lines 797-803 Link Here
797
797
798
  hp = gethostbyname(cp);
798
  hp = gethostbyname(cp);
799
  if (hp && hp->h_addrtype == AF_INET)
799
  if (hp && hp->h_addrtype == AF_INET)
800
    bcopy(hp->h_addr, &ipaddr, hp->h_length);
800
    bcopy(hp->h_addr, &ipaddr, MIN(hp->h_length, sizeof ipaddr));
801
  else if (inet_aton(cp, &ipaddr) == 0)
801
  else if (inet_aton(cp, &ipaddr) == 0)
802
    ipaddr.s_addr = 0;
802
    ipaddr.s_addr = 0;
803
  return(ipaddr);
803
  return(ipaddr);
(-)src/usr.bin/whois/whois.c (-1 / +1 lines)
Lines 97-103 Link Here
97
	}
97
	}
98
	bzero((caddr_t)&sin, sizeof (sin));
98
	bzero((caddr_t)&sin, sizeof (sin));
99
	sin.sin_family = hp->h_addrtype;
99
	sin.sin_family = hp->h_addrtype;
100
	bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
100
	bcopy(hp->h_addr, (char *)&sin.sin_addr, MIN(hp->h_length, sin.sin_addr));
101
	sp = getservbyname("whois", "tcp");
101
	sp = getservbyname("whois", "tcp");
102
	if (sp == NULL) {
102
	if (sp == NULL) {
103
		(void)fprintf(stderr, "whois: whois/tcp: unknown service\n");
103
		(void)fprintf(stderr, "whois: whois/tcp: unknown service\n");
(-)src/usr.bin/telnet/commands.c (-5 / +5 lines)
Lines 2200-2208 Link Here
2200
		sin.sin_family = host->h_addrtype;
2200
		sin.sin_family = host->h_addrtype;
2201
#if	defined(h_addr)		/* In 4.3, this is a #define */
2201
#if	defined(h_addr)		/* In 4.3, this is a #define */
2202
		memmove((caddr_t)&sin.sin_addr,
2202
		memmove((caddr_t)&sin.sin_addr,
2203
				host->h_addr_list[0], host->h_length);
2203
				host->h_addr_list[0], MIN(host->h_length, sizeof sin.sin_addr));
2204
#else	/* defined(h_addr) */
2204
#else	/* defined(h_addr) */
2205
		memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
2205
		memmove((caddr_t)&sin.sin_addr, host->h_addr, MIN(host->h_length, sizeof sin.sin_addr));
2206
#endif	/* defined(h_addr) */
2206
#endif	/* defined(h_addr) */
2207
		strncpy(_hostname, host->h_name, sizeof(_hostname));
2207
		strncpy(_hostname, host->h_name, sizeof(_hostname));
2208
		_hostname[sizeof(_hostname)-1] = '\0';
2208
		_hostname[sizeof(_hostname)-1] = '\0';
Lines 2294-2300 Link Here
2294
		perror((char *)0);
2294
		perror((char *)0);
2295
		host->h_addr_list++;
2295
		host->h_addr_list++;
2296
		memcpy((caddr_t)&sin.sin_addr,
2296
		memcpy((caddr_t)&sin.sin_addr,
2297
			host->h_addr_list[0], host->h_length);
2297
			host->h_addr_list[0], MIN(host->h_length, sizeof sin.sin_addr));
2298
		(void) NetClose(net);
2298
		(void) NetClose(net);
2299
		continue;
2299
		continue;
2300
	    }
2300
	    }
Lines 2779-2787 Link Here
2779
		} else if (host = gethostbyname(cp)) {
2779
		} else if (host = gethostbyname(cp)) {
2780
#if	defined(h_addr)
2780
#if	defined(h_addr)
2781
			memcpy((caddr_t)&sin_addr,
2781
			memcpy((caddr_t)&sin_addr,
2782
				host->h_addr_list[0], host->h_length);
2782
				host->h_addr_list[0], MIN(host->h_length, sizeof sin_addr));
2783
#else
2783
#else
2784
			memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length);
2784
			memcpy((caddr_t)&sin_addr, host->h_addr, MIN(host->h_length, sizeof sin_addr));
2785
#endif
2785
#endif
2786
		} else {
2786
		} else {
2787
			*cpp = cp;
2787
			*cpp = cp;
(-)src/usr.bin/talk/get_addrs.c (-1 / +1 lines)
Lines 56-62 Link Here
56
		herror((char *)NULL);
56
		herror((char *)NULL);
57
		exit(-1);
57
		exit(-1);
58
	}
58
	}
59
	bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
59
	bcopy(hp->h_addr, (char *) &his_machine_addr, MIN(hp->h_length, sizeof his_machine_addr));
60
	if (get_iface(&his_machine_addr, &my_machine_addr) == -1) {
60
	if (get_iface(&his_machine_addr, &my_machine_addr) == -1) {
61
		perror("failed to find my interface address");
61
		perror("failed to find my interface address");
62
		exit(-1);
62
		exit(-1);
(-)src/usr.bin/rpcinfo/rpcinfo.c (-2 / +2 lines)
Lines 494-500 Link Here
494
		server_addr.sin_family = AF_INET;
494
		server_addr.sin_family = AF_INET;
495
		if ((hp = gethostbyname("localhost")) != NULL)
495
		if ((hp = gethostbyname("localhost")) != NULL)
496
			bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
496
			bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
497
			    hp->h_length);
497
			    MIN(hp->h_length, sizeof server_addr.sin_addr));
498
		else
498
		else
499
			server_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
499
			server_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
500
	}
500
	}
Lines 660-666 Link Here
660
			fprintf(stderr, "rpcinfo: %s is unknown host\n", host);
660
			fprintf(stderr, "rpcinfo: %s is unknown host\n", host);
661
			exit(1);
661
			exit(1);
662
		}
662
		}
663
		bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length);
663
		bcopy(hp->h_addr, (char *)&addr->sin_addr, MIN(hp->h_length, sizeof addr->sin_addr));
664
	}
664
	}
665
	addr->sin_family = AF_INET;
665
	addr->sin_family = AF_INET;
666
}
666
}
(-)src/usr.bin/quota/quota.c (-1 / +1 lines)
Lines 702-708 Link Here
702
		return ((int) RPC_UNKNOWNHOST);
702
		return ((int) RPC_UNKNOWNHOST);
703
	timeout.tv_usec = 0;
703
	timeout.tv_usec = 0;
704
	timeout.tv_sec = 6;
704
	timeout.tv_sec = 6;
705
	bcopy(hp->h_addr, &server_addr.sin_addr, hp->h_length);
705
	bcopy(hp->h_addr, &server_addr.sin_addr, MIN(hp->h_length, sizeof server_addr.sin_addr));
706
	server_addr.sin_family = AF_INET;
706
	server_addr.sin_family = AF_INET;
707
	server_addr.sin_port =  0;
707
	server_addr.sin_port =  0;
708
708
(-)src/usr.bin/ftp/ftp.c (-3 / +4 lines)
Lines 86-92 Link Here
86
{
86
{
87
	struct hostent *hp = 0;
87
	struct hostent *hp = 0;
88
	int s, len, tos;
88
	int s, len, tos;
89
	static char hostnamebuf[80];
89
	static char hostnamebuf[128];
90
90
91
	memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
91
	memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
92
	hisctladdr.sin_addr.s_addr = inet_addr(host);
92
	hisctladdr.sin_addr.s_addr = inet_addr(host);
Lines 102-109 Link Here
102
		}
102
		}
103
		hisctladdr.sin_family = hp->h_addrtype;
103
		hisctladdr.sin_family = hp->h_addrtype;
104
		memmove((caddr_t)&hisctladdr.sin_addr,
104
		memmove((caddr_t)&hisctladdr.sin_addr,
105
				hp->h_addr_list[0], hp->h_length);
105
				hp->h_addr_list[0], MIN(hp->h_length, sizeof hisctladdr.sin_addr));
106
		(void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
106
		(void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
107
		hostnamebuf[sizeof hostnamebuf]='\0';
107
	}
108
	}
108
	hostname = hostnamebuf;
109
	hostname = hostnamebuf;
109
	s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
110
	s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
Lines 123-129 Link Here
123
			warn("connect to address %s", ia);
124
			warn("connect to address %s", ia);
124
			hp->h_addr_list++;
125
			hp->h_addr_list++;
125
			memmove((caddr_t)&hisctladdr.sin_addr,
126
			memmove((caddr_t)&hisctladdr.sin_addr,
126
					hp->h_addr_list[0], hp->h_length);
127
					hp->h_addr_list[0], MIN(hp->h_length, sizeof hisctladdr.sin_addr));
127
			fprintf(stdout, "Trying %s...\n",
128
			fprintf(stdout, "Trying %s...\n",
128
				inet_ntoa(hisctladdr.sin_addr));
129
				inet_ntoa(hisctladdr.sin_addr));
129
			(void) close(s);
130
			(void) close(s);
(-)src/usr.bin/finger/net.c (-1 / +1 lines)
Lines 91-97 Link Here
91
		return;
91
		return;
92
	}
92
	}
93
	sin.sin_family = hp->h_addrtype;
93
	sin.sin_family = hp->h_addrtype;
94
	bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
94
	bcopy(hp->h_addr, (char *)&sin.sin_addr, MIN(hp->h_length, sizeof sin.sin_addr));
95
	sin.sin_port = sp->s_port;
95
	sin.sin_port = sp->s_port;
96
	if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
96
	if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
97
		perror("finger: socket");
97
		perror("finger: socket");
(-)src/usr.bin/fetch/main.c (-1 / +2 lines)
Lines 30-35 Link Here
30
#include <sys/socket.h>
30
#include <sys/socket.h>
31
#include <sys/stat.h>
31
#include <sys/stat.h>
32
#include <sys/time.h>
32
#include <sys/time.h>
33
#include <sys/param.h>
33
#include <stdlib.h>
34
#include <stdlib.h>
34
#include <stdio.h>
35
#include <stdio.h>
35
#include <string.h>
36
#include <string.h>
Lines 740-746 Link Here
740
	if (!h) 
741
	if (!h) 
741
	    err (1, "could not lookup host %s.", host);
742
	    err (1, "could not lookup host %s.", host);
742
	sin.sin_family = h->h_addrtype;
743
	sin.sin_family = h->h_addrtype;
743
	bcopy(h->h_addr, (char *)&sin.sin_addr, h->h_length);
744
	bcopy(h->h_addr, (char *)&sin.sin_addr, MIN(h->h_length, sizeof sin.sin_addr));
744
    }
745
    }
745
    sin.sin_port = htons (http_port);
746
    sin.sin_port = htons (http_port);
746
    if ((s = socket (sin.sin_family, SOCK_STREAM, 0)) < 0) 
747
    if ((s = socket (sin.sin_family, SOCK_STREAM, 0)) < 0) 
(-)src/sbin/umount/umount.c (-1 / +1 lines)
Lines 250-256 Link Here
250
		memset(&saddr, 0, sizeof(saddr));
250
		memset(&saddr, 0, sizeof(saddr));
251
		saddr.sin_family = AF_INET;
251
		saddr.sin_family = AF_INET;
252
		saddr.sin_port = 0;
252
		saddr.sin_port = 0;
253
		memmove(&saddr.sin_addr, hp->h_addr, hp->h_length);
253
		memmove(&saddr.sin_addr, hp->h_addr, MIN(hp->h_length, sizeof saddr.sin_addr));
254
		pertry.tv_sec = 3;
254
		pertry.tv_sec = 3;
255
		pertry.tv_usec = 0;
255
		pertry.tv_usec = 0;
256
		so = RPC_ANYSOCK;
256
		so = RPC_ANYSOCK;
(-)src/sbin/route/route.c (-2 / +2 lines)
Lines 725-731 Link Here
725
		if (af == AF_INET && *gateway && hp && hp->h_addr_list[1]) {
725
		if (af == AF_INET && *gateway && hp && hp->h_addr_list[1]) {
726
			hp->h_addr_list++;
726
			hp->h_addr_list++;
727
			bcopy(hp->h_addr_list[0], &so_gate.sin.sin_addr,
727
			bcopy(hp->h_addr_list[0], &so_gate.sin.sin_addr,
728
			    hp->h_length);
728
			    MIN(hp->h_length, sizeof so_gate.sin.sin_addr));
729
		} else
729
		} else
730
			break;
730
			break;
731
	}
731
	}
Lines 989-995 Link Here
989
	if (hp) {
989
	if (hp) {
990
		*hpp = hp;
990
		*hpp = hp;
991
		su->sin.sin_family = hp->h_addrtype;
991
		su->sin.sin_family = hp->h_addrtype;
992
		bcopy(hp->h_addr, (char *)&su->sin.sin_addr, hp->h_length);
992
		bcopy(hp->h_addr, (char *)&su->sin.sin_addr, MIN(hp->h_length, sizeof su->sin.sin_addr));
993
		return (1);
993
		return (1);
994
	}
994
	}
995
	errx(EX_NOHOST, "bad address: %s", s);
995
	errx(EX_NOHOST, "bad address: %s", s);
(-)src/sbin/ping/ping.c (-1 / +1 lines)
Lines 305-311 Link Here
305
			exit(1);
305
			exit(1);
306
		}
306
		}
307
		to->sin_family = hp->h_addrtype;
307
		to->sin_family = hp->h_addrtype;
308
		bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length);
308
		bcopy(hp->h_addr, (caddr_t)&to->sin_addr, MIN(hp->h_length, sizeof to->sin_addr));
309
		(void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
309
		(void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
310
		hostname = hnamebuf;
310
		hostname = hnamebuf;
311
	}
311
	}
(-)src/sbin/mount_nfs/mount_nfs.c (-2 / +2 lines)
Lines 609-615 Link Here
609
			return (0);
609
			return (0);
610
		}
610
		}
611
	} else if ((hp = gethostbyname(hostp)) != NULL) {
611
	} else if ((hp = gethostbyname(hostp)) != NULL) {
612
		bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
612
		bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, MIN(hp->h_length, sizeof saddr.sin_addr));
613
	} else {
613
	} else {
614
		warnx("can't get net id for host");
614
		warnx("can't get net id for host");
615
		return (0);
615
		return (0);
Lines 621-627 Link Here
621
			warnx("can't reverse resolve net address");
621
			warnx("can't reverse resolve net address");
622
			return (0);
622
			return (0);
623
		}
623
		}
624
		bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
624
		bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, MIN(hp->h_length, sizeof saddr.sin_addr));
625
		strncpy(inst, hp->h_name, INST_SZ);
625
		strncpy(inst, hp->h_name, INST_SZ);
626
		inst[INST_SZ - 1] = '\0';
626
		inst[INST_SZ - 1] = '\0';
627
		if (cp = strchr(inst, '.'))
627
		if (cp = strchr(inst, '.'))
(-)src/sbin/ifconfig/ifconfig.c (-1 / +1 lines)
Lines 969-975 Link Here
969
	if (inet_aton(s, &sin->sin_addr))
969
	if (inet_aton(s, &sin->sin_addr))
970
		return;
970
		return;
971
	if ((hp = gethostbyname(s)) != 0)
971
	if ((hp = gethostbyname(s)) != 0)
972
		bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length);
972
		bcopy(hp->h_addr, (char *)&sin->sin_addr, MIN(hp->h_length, sizeof sin->sin_addr));
973
	else if ((np = getnetbyname(s)) != 0)
973
	else if ((np = getnetbyname(s)) != 0)
974
		sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
974
		sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
975
	else
975
	else
(-)src/libexec/mail.local/mail.local.c (-1 / +1 lines)
Lines 346-352 Link Here
346
			return;
346
			return;
347
		}
347
		}
348
		addr.sin_family = hp->h_addrtype;
348
		addr.sin_family = hp->h_addrtype;
349
		memmove(&addr.sin_addr, hp->h_addr, hp->h_length);
349
		memmove(&addr.sin_addr, hp->h_addr, MIN(hp->h_length, sizeof addr.sin_addr));
350
		addr.sin_port = sp->s_port;
350
		addr.sin_port = sp->s_port;
351
	}
351
	}
352
	if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
352
	if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
(-)src/lib/libskey/skeyaccess.c (-2 / +1 lines)
Lines 408-419 Link Here
408
408
409
    for (i = 0; i < MAX_ADDR && hp->h_addr_list[i]; i++)
409
    for (i = 0; i < MAX_ADDR && hp->h_addr_list[i]; i++)
410
	memcpy((char *) &list[i],
410
	memcpy((char *) &list[i],
411
	       hp->h_addr_list[i], hp->h_length);
411
	       hp->h_addr_list[i], (length=MIN(hp->h_length, sizeof (struct in_addr)));
412
    list[i].s_addr = 0;
412
    list[i].s_addr = 0;
413
413
414
    strncpy(buf, hp->h_name, MAXHOSTNAMELEN);
414
    strncpy(buf, hp->h_name, MAXHOSTNAMELEN);
415
    buf[MAXHOSTNAMELEN] = 0;
415
    buf[MAXHOSTNAMELEN] = 0;
416
    length = hp->h_length;
417
416
418
    /*
417
    /*
419
     * Wipe addresses that appear to belong to someone else. We will get
418
     * Wipe addresses that appear to belong to someone else. We will get
(-)src/lib/libftpio/ftpio.c (-1 / +2 lines)
Lines 35-40 Link Here
35
#include <stdlib.h>
35
#include <stdlib.h>
36
#include <string.h>
36
#include <string.h>
37
#include <unistd.h>
37
#include <unistd.h>
38
#include <sys/param.h>
38
39
39
#define SUCCESS		 0
40
#define SUCCESS		 0
40
#define FAILURE		-1
41
#define FAILURE		-1
Lines 701-707 Link Here
701
	    return FAILURE;
702
	    return FAILURE;
702
	}
703
	}
703
	ftp->addrtype = sin.sin_family = he->h_addrtype;
704
	ftp->addrtype = sin.sin_family = he->h_addrtype;
704
	bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
705
	bcopy(he->h_addr, (char *)&sin.sin_addr, MIN(he->h_length, sizeof sin.sin_addr));
705
    }
706
    }
706
707
707
    sin.sin_port = htons(port);
708
    sin.sin_port = htons(port);

Return to bug 2586