mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Fix possible gethostbyname-related overflows as pointed out in
PR#bin/2585 .
This commit is contained in:
parent
81eb579301
commit
de5ae7f25a
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user