From 5b9ccc383d5af61c8d41ab99510c805929886461 Mon Sep 17 00:00:00 2001 From: mrg Date: Sat, 4 Jul 1998 21:31:59 +0000 Subject: [PATCH] use destination's size in 2 memcpy calls. --- usr.sbin/mrinfo/mrinfo.c | 8 ++++---- usr.sbin/mtrace/mtrace.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/usr.sbin/mrinfo/mrinfo.c b/usr.sbin/mrinfo/mrinfo.c index 4ce43a0895f3..8c950522ecb5 100644 --- a/usr.sbin/mrinfo/mrinfo.c +++ b/usr.sbin/mrinfo/mrinfo.c @@ -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; diff --git a/usr.sbin/mtrace/mtrace.c b/usr.sbin/mtrace/mtrace.c index 87a0f25fcd52..ce6b241edd9c 100644 --- a/usr.sbin/mtrace/mtrace.c +++ b/usr.sbin/mtrace/mtrace.c @@ -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 #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 @@ -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