use destination's size in 2 memcpy calls.

This commit is contained in:
mrg 1998-07-04 21:31:59 +00:00
parent 5a91a6622c
commit 5b9ccc383d
2 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mrinfo.c,v 1.6 1998/05/09 17:22:08 kleink Exp $ */
/* $NetBSD: mrinfo.c,v 1.7 1998/07/04 21:31:59 mrg Exp $ */
/*
* This tool requests configuration info from a multicast router
@ -67,7 +67,7 @@
static char rcsid[] =
"@(#) Header: mrinfo.c,v 1.6 93/04/08 15:14:16 van Exp (LBL)";
#else
__RCSID("$NetBSD: mrinfo.c,v 1.6 1998/05/09 17:22:08 kleink Exp $");
__RCSID("$NetBSD: mrinfo.c,v 1.7 1998/07/04 21:31:59 mrg Exp $");
#endif
#endif
@ -377,7 +377,7 @@ main(argc, argv)
hp->h_length = sizeof(target_addr);
hp->h_addr_list = (char **)malloc(2 * sizeof(char *));
hp->h_addr_list[0] = malloc(hp->h_length);
memcpy(hp->h_addr_list[0], &target_addr, hp->h_length);
memcpy(hp->h_addr_list[0], &target_addr, sizeof(hp->h_addr_list[0]));
hp->h_addr_list[1] = 0;
} else
hp = gethostbyname(host);
@ -393,7 +393,7 @@ main(argc, argv)
/* Check all addresses; mrouters often have unreachable interfaces */
for (curaddr = 0; hp->h_addr_list[curaddr] != NULL; curaddr++) {
memcpy(&target_addr, hp->h_addr_list[curaddr], hp->h_length);
memcpy(&target_addr, hp->h_addr_list[curaddr], sizeof(target_addr));
{ /* Find a good local address for us. */
int udp;
struct sockaddr_in addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtrace.c,v 1.9 1998/05/09 17:22:09 kleink Exp $ */
/* $NetBSD: mtrace.c,v 1.10 1998/07/04 21:34:20 mrg Exp $ */
/*
* mtrace.c
@ -52,7 +52,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mtrace.c,v 1.9 1998/05/09 17:22:09 kleink Exp $");
__RCSID("$NetBSD: mtrace.c,v 1.10 1998/07/04 21:34:20 mrg Exp $");
#endif
#include <sys/types.h>
@ -212,7 +212,7 @@ host_addr(name)
*op = '\0';
if (dots <= 0) e = gethostbyname(name);
if (e) memcpy((char *)&addr, e->h_addr_list[0], e->h_length);
if (e) memcpy((char *)&addr, e->h_addr_list[0], sizeof(addr));
else {
addr = inet_addr(buf);
if (addr == -1) {
@ -1367,7 +1367,8 @@ Usage: mtrace [-Mlnps] [-w wait] [-m max_hops] [-q nqueries] [-g gateway]\n\
exit(-1);
}
memcpy((char *)&addr.sin_addr.s_addr, hp->h_addr, hp->h_length);
memcpy((char *)&addr.sin_addr.s_addr, hp->h_addr,
sizeof(addr.sin_addr.s_addr));
}
#endif