diff --git a/CHANGELOG.md b/CHANGELOG.md index d83c55eec..c8488385e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Add function ldap_enable_debug () [#453](https://github.com/greenbone/gvm-libs/pull/453) - Ensure that new kb taken by the scanner are always clean. [#469](https://github.com/greenbone/gvm-libs/pull/469) +- Validate for max_scan_hosts scanner preference. [#482](https://github.com/greenbone/gvm-libs/pull/482) ### Changed Use a char pointer instead of an zero-lenght array as kb_redis struct member. [443](https://github.com/greenbone/gvm-libs/pull/443) diff --git a/boreas/alivedetection.c b/boreas/alivedetection.c index 3e40c816d..8513a7008 100644 --- a/boreas/alivedetection.c +++ b/boreas/alivedetection.c @@ -256,9 +256,19 @@ alive_detection_init (gvm_hosts_t *hosts, alive_test_t alive_test) /* Scan restrictions. max_scan_hosts related. */ const gchar *pref_str; - int max_scan_hosts = INT_MAX; + int max_scan_hosts = INT_MAX, pref_value; + + /* Check that the max_scan_hosts is set and it is greater than 0 */ if ((pref_str = prefs_get ("max_scan_hosts")) != NULL) - max_scan_hosts = atoi (pref_str); + { + pref_value = atoi (pref_str); + if (pref_value > 0) + max_scan_hosts = pref_value; + else + g_debug ("%s: Invalid max_scan_hosts value. It must be an interger " + "greater than zero.", + __func__); + } init_scan_restrictions (&scanner, max_scan_hosts);