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

Fix SIGSEGV when no best route is found. #702

Merged
merged 2 commits into from
Apr 16, 2021
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 @@ -21,6 +21,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