Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always NULL check ifaddrs->ifa_addr #415

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions base/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ gvm_source_iface_init (const char *iface)
{
if (ifa->ifa_addr && strcmp (iface, ifa->ifa_name) == 0)
{
if (ifa->ifa_addr->sa_family == AF_INET)
if (ifa->ifa_addr
&& (ifa->ifa_addr->sa_family == AF_INET))
{
struct in_addr *addr =
&((struct sockaddr_in *) ifa->ifa_addr)->sin_addr;

memcpy (&global_source_addr, addr, sizeof (global_source_addr));
ret = 0;
}
else if (ifa->ifa_addr->sa_family == AF_INET6)
else if (ifa->ifa_addr
&& (ifa->ifa_addr->sa_family == AF_INET6))
{
struct sockaddr_in6 *addr;

Expand Down Expand Up @@ -1031,7 +1033,8 @@ gvm_routethrough (struct sockaddr_storage *storage_dest,

for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if ((ifa->ifa_addr->sa_family == AF_INET)
if (ifa->ifa_addr
&& (ifa->ifa_addr->sa_family == AF_INET)
&& (ifa->ifa_flags & (IFF_LOOPBACK)))
{
interface_out = g_strdup (ifa->ifa_name);
Expand Down Expand Up @@ -1079,7 +1082,8 @@ gvm_routethrough (struct sockaddr_storage *storage_dest,
{
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if ((ifa->ifa_addr->sa_family == AF_INET)
if (ifa->ifa_addr
&& (ifa->ifa_addr->sa_family == AF_INET)
&& (g_strcmp0 (interface_out, ifa->ifa_name)
== 0))
{
Expand Down