Skip to content

Commit

Permalink
Fix SIGSEGV when no best route is found.
Browse files Browse the repository at this point in the history
In some case there is no a best route, and no source route can be assigned.
This fix set source with the address in the first route found in the route table
or 0.0.0.0 in case an empty route table.

(cherry picked from commit ad9499b)
  • Loading branch information
jjnicola authored and mergify-bot committed Apr 16, 2021
1 parent a43935c commit 8b277cf
Show file tree
Hide file tree
Showing 2 changed files with 15 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
15 changes: 14 additions & 1 deletion misc/pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,26 @@ 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;
/* or any */
else
source->s_addr = INADDR_ANY;
}
}

if (best_match != -1)
Expand Down

0 comments on commit 8b277cf

Please sign in to comment.