diff options
author | Bill Fenner <fenner@FreeBSD.org> | 1997-02-09 22:32:04 +0000 |
---|---|---|
committer | Bill Fenner <fenner@FreeBSD.org> | 1997-02-09 22:32:04 +0000 |
commit | de5ae7f25a86bb6bae3bfeba2c3dea8146f0c233 (patch) | |
tree | 852197caa2ad5f818c175d47526725d66ee48ed3 /usr.sbin/mrouted | |
parent | 81eb579301e3f52fed225ad4b3eff665a5f56b2c (diff) | |
download | src-de5ae7f25a86bb6bae3bfeba2c3dea8146f0c233.tar.gz src-de5ae7f25a86bb6bae3bfeba2c3dea8146f0c233.zip |
Fix possible gethostbyname-related overflows as pointed out in
PR#bin/2585 .
Notes
Notes:
svn path=/head/; revision=22513
Diffstat (limited to 'usr.sbin/mrouted')
-rw-r--r-- | usr.sbin/mrouted/mapper.c | 2 | ||||
-rw-r--r-- | usr.sbin/mrouted/mrinfo.c | 2 | ||||
-rw-r--r-- | usr.sbin/mrouted/mtrace.c | 3 |
3 files changed, 4 insertions, 3 deletions
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)) { |