From 176f1a8eb7bfef07b07d9fd3e1642db5ebc5fa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Tue, 14 Nov 2023 11:39:38 +0100 Subject: [PATCH] Handle return value of probe_item_collect 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. --- src/OVAL/probes/independent/textfilecontent54_probe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OVAL/probes/independent/textfilecontent54_probe.c b/src/OVAL/probes/independent/textfilecontent54_probe.c index d3a5c6eb22..4c6c9a1fa1 100644 --- a/src/OVAL/probes/independent/textfilecontent54_probe.c +++ b/src/OVAL/probes/independent/textfilecontent54_probe.c @@ -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);