Skip to content

Commit

Permalink
Fix Coverity warning in sk_interface_addr().
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mlichvar authored and richardcochran committed Sep 21, 2014
1 parent 9ddd2a6 commit 6b459ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6b459ab

Please sign in to comment.