Skip to content

Commit

Permalink
Merge pull request #707 from greenbone/mergify/bp/master/pr-702
Browse files Browse the repository at this point in the history
Fix SIGSEGV when no best route is found. (backport #702)
  • Loading branch information
jjnicola authored Apr 16, 2021
2 parents a43935c + 8c53f8e commit 101164a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix gcc-9 and gcc-10 warnings. [#655](https://github.com/greenbone/openvas/pull/655)
- Fix double free in nasl_cert_query. [#658](https://github.com/greenbone/openvas/pull/658)
- Fix message to the client if there is a iface problem. [#695](https://github.com/greenbone/openvas/pull/695)
- Fix SIGSEGV when no best route is found. [#702](https://github.com/greenbone/openvas/pull/702)

### Removed
- Remove code from the openvas daemon era. Do not flushall redis. [#689](https://github.com/greenbone/openvas/pull/689)
Expand Down
18 changes: 17 additions & 1 deletion misc/pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,29 @@ routethrough (struct in_addr *dest, struct in_addr *source)
}
}
}

/* Set source */
if (source)
{
/* Source address is given */
if (src.s_addr != INADDR_ANY)
source->s_addr = src.s_addr;
else
/* Source address is INADDR_ANY and there is a good route */
else if (best_match != -1)
source->s_addr = myroutes[best_match].dev->addr.s_addr;
/* No best route found and no default */
else
{
/* Assigned first route in the table */
if (myroutes[0].dev)
{
source->s_addr = myroutes[0].dev->addr.s_addr;
best_match = 0;
}
/* or any */
else
source->s_addr = INADDR_ANY;
}
}

if (best_match != -1)
Expand Down

0 comments on commit 101164a

Please sign in to comment.