mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-03 10:01:24 +02:00
fixed a crash due to invalid sockaddr cast
This commit is contained in:
parent
4d0eeb257e
commit
15fa335343
@ -1357,15 +1357,18 @@ NetworkInterface::Type fromNative(u_char nativeType)
|
|||||||
|
|
||||||
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
|
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
|
||||||
{
|
{
|
||||||
struct sockaddr_dl* sdl = (struct sockaddr_dl*) iface->ifa_addr;
|
|
||||||
impl.setName(iface->ifa_name);
|
impl.setName(iface->ifa_name);
|
||||||
impl.setDisplayName(iface->ifa_name);
|
impl.setDisplayName(iface->ifa_name);
|
||||||
impl.setAdapterName(iface->ifa_name);
|
impl.setAdapterName(iface->ifa_name);
|
||||||
impl.setPhyParams();
|
impl.setPhyParams();
|
||||||
|
|
||||||
|
if (iface->ifa_addr->sa_family == AF_LINK)
|
||||||
|
{
|
||||||
|
struct sockaddr_dl* sdl = (struct sockaddr_dl*) iface->ifa_addr;
|
||||||
impl.setMACAddress(LLADDR(sdl), sdl->sdl_alen);
|
impl.setMACAddress(LLADDR(sdl), sdl->sdl_alen);
|
||||||
impl.setType(fromNative(sdl->sdl_type));
|
impl.setType(fromNative(sdl->sdl_type));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -1536,9 +1539,12 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
|
|||||||
impl.setPhyParams();
|
impl.setPhyParams();
|
||||||
|
|
||||||
#ifndef POCO_NO_LINUX_IF_PACKET_H
|
#ifndef POCO_NO_LINUX_IF_PACKET_H
|
||||||
|
if (iface->ifa_addr->sa_family == AF_PACKET)
|
||||||
|
{
|
||||||
struct sockaddr_ll* sdl = (struct sockaddr_ll*) iface->ifa_addr;
|
struct sockaddr_ll* sdl = (struct sockaddr_ll*) iface->ifa_addr;
|
||||||
impl.setMACAddress(sdl->sll_addr, sdl->sll_halen);
|
impl.setMACAddress(sdl->sll_addr, sdl->sll_halen);
|
||||||
impl.setType(fromNative(sdl->sll_hatype));
|
impl.setType(fromNative(sdl->sll_hatype));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
std::string ifPath("/sys/class/net/");
|
std::string ifPath("/sys/class/net/");
|
||||||
ifPath += iface->ifa_name;
|
ifPath += iface->ifa_name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user