Skip to content

Commit

Permalink
Fix: Fix results filter column handling
Browse files Browse the repository at this point in the history
Table prefixes have been added to the id and uuid columns of result
iterators and an invalid pointer in column_array_free has been fixed.

This addresses SQL and memory errors when filtering results.
  • Loading branch information
timopollmeier committed Mar 14, 2024
1 parent e109bf9 commit c552f8f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,11 +1030,12 @@ column_array_copy (column_t *columns)
static void
column_array_free (column_t *columns)
{
while (columns->filter)
column_t *point = columns;
while (point->filter)
{
g_free (columns->select);
g_free (columns->filter);
columns++;
g_free (point->select);
g_free (point->filter);
point++;
}
g_free (columns);
}
Expand Down Expand Up @@ -22158,8 +22159,8 @@ where_qod (int min_qod)
* @brief Result iterator filterable columns, for severity only version .
*/
#define BASE_RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "results.id", "id", KEYWORD_TYPE_INTEGER }, \
{ "results.uuid", "uuid", KEYWORD_TYPE_STRING }, \
{ "(SELECT name FROM nvts WHERE nvts.oid = nvt)", \
"name", \
KEYWORD_TYPE_STRING }, \
Expand Down Expand Up @@ -22310,9 +22311,9 @@ where_qod (int min_qod)
* @brief Result iterator columns.
*/
#define PRE_BASE_RESULT_ITERATOR_COLUMNS(new_severity_sql) \
{ "results.id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "results.id", "id", KEYWORD_TYPE_INTEGER }, \
/* ^ 0 */ \
{ "results.uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "results.uuid", "uuid", KEYWORD_TYPE_STRING }, \
{ "nvts.name", \
"name", \
KEYWORD_TYPE_STRING }, \
Expand Down

0 comments on commit c552f8f

Please sign in to comment.