File tree 1 file changed +23
-3
lines changed
1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -1264,7 +1264,7 @@ get_member_value_or_fail (cJSON *reader, const gchar *member)
1264
1264
{
1265
1265
cJSON * item = NULL ;
1266
1266
if ((item = cJSON_GetObjectItem (reader , member )) == NULL
1267
- && cJSON_IsNumber (item ))
1267
+ || ! cJSON_IsNumber (item ))
1268
1268
return -1 ;
1269
1269
1270
1270
return item -> valueint ;
@@ -1330,7 +1330,27 @@ openvasd_get_scan_progress_ext (openvasd_connector_t conn,
1330
1330
cJSON * host = scanning -> child ;
1331
1331
while (host )
1332
1332
{
1333
- running_hosts_progress_sum += cJSON_GetNumberValue (host );
1333
+ int finished_tests , total_tests , single_host_progress ;
1334
+
1335
+ if (!cJSON_IsObject (host ))
1336
+ {
1337
+ g_message ("NO ES OBJETO" );
1338
+ progress = 0 ;
1339
+ goto cleanup ;
1340
+ }
1341
+
1342
+ finished_tests = get_member_value_or_fail (host , "finished_tests" );
1343
+ total_tests = get_member_value_or_fail (host , "total_tests" );
1344
+
1345
+ if (total_tests < 0 || finished_tests < 0 )
1346
+ {
1347
+ progress = 0 ;
1348
+ goto cleanup ;
1349
+ }
1350
+
1351
+ single_host_progress = (100 * finished_tests / total_tests );
1352
+
1353
+ running_hosts_progress_sum += single_host_progress ;
1334
1354
host = host -> next ;
1335
1355
}
1336
1356
@@ -1347,7 +1367,7 @@ openvasd_get_scan_progress_ext (openvasd_connector_t conn,
1347
1367
progress = (running_hosts_progress_sum + 100 * (alive + finished ))
1348
1368
/ (all + finished - dead );
1349
1369
else
1350
- progress = 100 ;
1370
+ progress = 0 ;
1351
1371
1352
1372
cleanup :
1353
1373
if (err != NULL )
You can’t perform that action at this time.
0 commit comments