Skip to content

Commit

Permalink
Fix: segmentation fault and false positive on empty function body
Browse files Browse the repository at this point in the history
On segfault.nasl:

```
> cat segfault.nasl
function foo() {}
foo();
```

openvas-nasl-lint does not falsly identify an empty function as an
error and it is also not throwing a SEGFAULT.
  • Loading branch information
nichtsfrei committed May 24, 2022
1 parent 6e3a09f commit 248ef6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nasl/lint.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ static void
check_called_files (gpointer key, gpointer value, GSList **unusedfiles)
{
if (key != NULL)
if (g_strcmp0 (value, "YES") != 0)
// only check for includes not for main file
if (nasl_get_include_order ((const char *) key) > 0
&& g_strcmp0 (value, "YES") != 0)
*unusedfiles = g_slist_prepend (*unusedfiles, key);
}

Expand Down Expand Up @@ -433,7 +435,7 @@ is_deffunc_used (const char *funcname, const char *filename,
return 1;
current = current->next;
}
while (current->next != NULL);
while (current != NULL && current->next != NULL);
return 0;
}

Expand Down

0 comments on commit 248ef6d

Please sign in to comment.