mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
ID: 256 - ipmitool could crash when IPv6 address is returned
gethostbyname() can't handle IPv6. Despite this fact it seems worth of nothing to check whether gethostbyname() really returned AF_INET or not. And that's what attached patch does, resp. in case IPv6 is returned then ipmitool shoud/will terminate.
This commit is contained in:
parent
8a40297308
commit
9f51d8f188
@ -494,6 +494,13 @@ ipmi_dcmi_prnt_oobDiscover(struct ipmi_intf * intf)
|
|||||||
s->hostname);
|
s->hostname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (host->h_addrtype != AF_INET) {
|
||||||
|
lprintf(LOG_ERR,
|
||||||
|
"Address lookup for %s failed. Got %s, expected IPv4 address.",
|
||||||
|
s->hostname,
|
||||||
|
(host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
s->addr.sin_family = host->h_addrtype;
|
s->addr.sin_family = host->h_addrtype;
|
||||||
memcpy(&s->addr.sin_addr, host->h_addr, host->h_length);
|
memcpy(&s->addr.sin_addr, host->h_addr, host->h_length);
|
||||||
}
|
}
|
||||||
|
@ -437,6 +437,13 @@ ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv)
|
|||||||
intf->session->hostname);
|
intf->session->hostname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (host->h_addrtype != AF_INET) {
|
||||||
|
lprintf(LOG_ERR,
|
||||||
|
"Address lookup for %s failed. Got %s, expected IPv4 address.",
|
||||||
|
intf->session->hostname,
|
||||||
|
(host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
intf->session->addr.sin_family = host->h_addrtype;
|
intf->session->addr.sin_family = host->h_addrtype;
|
||||||
memcpy(&intf->session->addr.sin_addr, host->h_addr, host->h_length);
|
memcpy(&intf->session->addr.sin_addr, host->h_addr, host->h_length);
|
||||||
}
|
}
|
||||||
|
@ -2045,6 +2045,13 @@ ipmi_lan_open(struct ipmi_intf * intf)
|
|||||||
s->hostname);
|
s->hostname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (host->h_addrtype != AF_INET) {
|
||||||
|
lprintf(LOG_ERR,
|
||||||
|
"Address lookup for %s failed. Got %s, expected IPv4 address.",
|
||||||
|
s->hostname,
|
||||||
|
(host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
s->addr.sin_family = host->h_addrtype;
|
s->addr.sin_family = host->h_addrtype;
|
||||||
memcpy(&s->addr.sin_addr, host->h_addr, host->h_length);
|
memcpy(&s->addr.sin_addr, host->h_addr, host->h_length);
|
||||||
}
|
}
|
||||||
|
@ -3387,6 +3387,13 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
|
|||||||
session->hostname);
|
session->hostname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (host->h_addrtype != AF_INET) {
|
||||||
|
lprintf(LOG_ERR,
|
||||||
|
"Address lookup for %s failed. Got %s, expected IPv4 address.",
|
||||||
|
session->hostname,
|
||||||
|
(host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
addr.sin_family = host->h_addrtype;
|
addr.sin_family = host->h_addrtype;
|
||||||
memcpy(&addr.sin_addr, host->h_addr, host->h_length);
|
memcpy(&addr.sin_addr, host->h_addr, host->h_length);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user