Skip to content

Commit

Permalink
Merge pull request #888 from Kraemii/fix-host-segfault
Browse files Browse the repository at this point in the history
use duplicate host function
  • Loading branch information
Kraemii authored Oct 7, 2021
2 parents dd3eb66 + 0202fb4 commit 30f0fd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Use fchmod to change file permission instead of on open to prevent race conditions [860](https://github.com/greenbone/openvas-scanner/pull/860)
- Fix plugins upload. Backport #878. [#879](https://github.com/greenbone/openvas/pull/879)
- Fix Segmentation fault when freeing hosts and alive hosts [#888](https://github.com/greenbone/openvas/pull/888)

## [21.10] (unreleased)

Expand Down
14 changes: 9 additions & 5 deletions src/attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@ attack_network (struct scan_globals *globals)
if (test_alive_hosts_only)
{
struct in6_addr tmpaddr;
gvm_host_t *buf;

while (1)
{
Expand Down Expand Up @@ -1231,13 +1232,16 @@ attack_network (struct scan_globals *globals)
break;
}

if (gvm_host_get_addr6 (host, &tmpaddr) == 0)
host = gvm_host_find_in_hosts (host, &tmpaddr, hosts);

if (host)
if (host && gvm_host_get_addr6 (host, &tmpaddr) == 0)
{
gvm_hosts_add (alive_hosts_list, host);
buf = host;
host = gvm_host_find_in_hosts (host, &tmpaddr, hosts);
gvm_host_free (buf);
buf = NULL;
}

if (host)
gvm_hosts_add (alive_hosts_list, gvm_duplicate_host (host));
else
g_debug ("%s: got NULL host, stop/finish scan", __func__);
}
Expand Down

0 comments on commit 30f0fd3

Please sign in to comment.