diff --git a/usr.sbin/mrouted/mapper.c b/usr.sbin/mrouted/mapper.c index aa5aabddf8f0..3691aeaefa4b 100644 --- a/usr.sbin/mrouted/mapper.c +++ b/usr.sbin/mrouted/mapper.c @@ -826,7 +826,7 @@ u_int32 host_addr(name) struct hostent *e = gethostbyname(name); int addr; - if (e) + if (e && e->h_length == sizeof(addr)) memcpy(&addr, e->h_addr_list[0], e->h_length); else { addr = inet_addr(name); diff --git a/usr.sbin/mrouted/mrinfo.c b/usr.sbin/mrouted/mrinfo.c index 58e5544dfb23..2467c3d5b41b 100644 --- a/usr.sbin/mrouted/mrinfo.c +++ b/usr.sbin/mrouted/mrinfo.c @@ -383,7 +383,7 @@ main(argc, argv) } else hp = gethostbyname(host); - if (hp == NULL) { + if (hp == NULL || hp->h_length != sizeof(target_addr)) { fprintf(stderr, "mrinfo: %s: no such host\n", argv[0]); exit(1); } diff --git a/usr.sbin/mrouted/mtrace.c b/usr.sbin/mrouted/mtrace.c index 2164b91a1b7b..9ffa1852ee56 100644 --- a/usr.sbin/mrouted/mtrace.c +++ b/usr.sbin/mrouted/mtrace.c @@ -759,7 +759,8 @@ 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 && e->h_length == sizeof(addr)) + memcpy((char *)&addr, e->h_addr_list[0], e->h_length); else { addr = inet_addr(buf); if (addr == -1 || (IN_MULTICAST(addr) && dots)) {