diff --git a/CHANGELOG.md b/CHANGELOG.md index 0522c04e5..9b1a0d4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/misc/pcap.c b/misc/pcap.c index a50e458fb..de9b5e858 100644 --- a/misc/pcap.c +++ b/misc/pcap.c @@ -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)