Fix Coverity warning in sk_interface_addr().
Copy the address directly to struct sockaddr_in or sockaddr_in6 instead of sockaddr as Coverity doesn't seem to understand the union and reports a buffer overflow. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
9ddd2a6024
commit
6b459abc8c
3
sk.c
3
sk.c
|
@ -191,14 +191,15 @@ int sk_interface_addr(const char *name, int family, struct address *addr)
|
||||||
switch (family) {
|
switch (family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
addr->len = sizeof(addr->sin);
|
addr->len = sizeof(addr->sin);
|
||||||
|
memcpy(&addr->sin, i->ifa_addr, addr->len);
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
addr->len = sizeof(addr->sin6);
|
addr->len = sizeof(addr->sin6);
|
||||||
|
memcpy(&addr->sin6, i->ifa_addr, addr->len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
memcpy(&addr->sa, i->ifa_addr, addr->len);
|
|
||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue