Miroslav Lichvar
2014-09-17 09:11:16 UTC
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 <***@redhat.com>
---
sk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sk.c b/sk.c
index a9133fd..c48cf45 100644
--- a/sk.c
+++ b/sk.c
@@ -191,14 +191,15 @@ int sk_interface_addr(const char *name, int family, struct address *addr)
switch (family) {
case AF_INET:
addr->len = sizeof(addr->sin);
+ memcpy(&addr->sin, i->ifa_addr, addr->len);
break;
case AF_INET6:
addr->len = sizeof(addr->sin6);
+ memcpy(&addr->sin6, i->ifa_addr, addr->len);
break;
default:
continue;
}
- memcpy(&addr->sa, i->ifa_addr, addr->len);
result = 0;
break;
}
of sockaddr as Coverity doesn't seem to understand the union and reports
a buffer overflow.
Signed-off-by: Miroslav Lichvar <***@redhat.com>
---
sk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sk.c b/sk.c
index a9133fd..c48cf45 100644
--- a/sk.c
+++ b/sk.c
@@ -191,14 +191,15 @@ int sk_interface_addr(const char *name, int family, struct address *addr)
switch (family) {
case AF_INET:
addr->len = sizeof(addr->sin);
+ memcpy(&addr->sin, i->ifa_addr, addr->len);
break;
case AF_INET6:
addr->len = sizeof(addr->sin6);
+ memcpy(&addr->sin6, i->ifa_addr, addr->len);
break;
default:
continue;
}
- memcpy(&addr->sa, i->ifa_addr, addr->len);
result = 0;
break;
}
--
1.9.3
1.9.3