Skip to content

Commit

Permalink
Handle return value of probe_item_collect
Browse files Browse the repository at this point in the history
The `probe_item_collect` function can fail and it can return various
return codes. But, the return codes aren't handled in the caller
function `process_file`. That means the `process_file` continues to
process items even if no other items can be collected due to memory
constraints or other problems. With this commit, we will read the return
code of `probe_item_collect` and react accordingly.
  • Loading branch information
jan-cerny committed Nov 14, 2023
1 parent 5e3d8bc commit 176f1a8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/OVAL/probes/independent/textfilecontent54_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,14 @@ static int process_file(const char *prefix, const char *path, const char *file,
item = create_item(path, file, pfd->pattern,
cur_inst, substrs, substr_cnt, over);

probe_item_collect(pfd->ctx, item);

for (k = 0; k < substr_cnt; ++k)
free(substrs[k]);
free(substrs);
int pic_ret = probe_item_collect(pfd->ctx, item);
if (pic_ret == 2 || pic_ret == -1) {
ret = -4;
break;
}
}
}
} while (substr_cnt > 0 && ofs < buf_used);
Expand Down

0 comments on commit 176f1a8

Please sign in to comment.