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 #416

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix port list for tcp pings when using test_alive_hosts_only feature. [#392](https://github.com/greenbone/gvm-libs/pull/392)
- Set source address correctly and do not try to send ARP to unreachable destination. [#401](https://github.com/greenbone/gvm-libs/pull/401)
- Increase minimum gpgme version [#405](https://github.com/greenbone/gvm-libs/pull/405)
- Always NULL check ifaddrs->ifa_addr [#416](https://github.com/greenbone/gvm-libs/pull/416)

[20.8.1]: https://github.com/greenbone/gvm-libs/compare/v20.8.0...gvm-libs-20.08

Expand Down
5 changes: 3 additions & 2 deletions base/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ 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 +1079,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