Skip to content

Commit 65a40c5

Browse files
committed
Use blocked paths in fileextendedattribute probe
1 parent 830ea1d commit 65a40c5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/OVAL/probes/unix/fileextendedattribute_probe.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct cbargs {
7777
};
7878

7979
#if defined(OS_FREEBSD)
80-
static int file_cb(const char *prefix, const char *p, const char *f, void *ptr, SEXP_t *gr_lastpath)
80+
static int file_cb(const char *prefix, const char *p, const char *f, void *ptr, SEXP_t *gr_lastpath, struct oscap_list *blocked_paths)
8181
{
8282
char path_buffer[PATH_MAX];
8383
SEXP_t *item;
@@ -110,6 +110,10 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
110110
st_path = path_buffer;
111111
}
112112

113+
if (probe_path_is_blocked(st_path, blocked_paths)) {
114+
return 0;
115+
}
116+
113117
char *st_path_with_prefix = oscap_path_join(prefix, st_path);
114118

115119
/* update lastpath if needed */
@@ -205,7 +209,7 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
205209
}
206210

207211
#else
208-
static int file_cb(const char *prefix, const char *p, const char *f, void *ptr, SEXP_t *gr_lastpath)
212+
static int file_cb(const char *prefix, const char *p, const char *f, void *ptr, SEXP_t *gr_lastpath, struct oscap_list *blocked_paths)
209213
{
210214
char path_buffer[PATH_MAX];
211215
SEXP_t *item, xattr_name;
@@ -231,6 +235,10 @@ static int file_cb(const char *prefix, const char *p, const char *f, void *ptr,
231235

232236
SEXP_init(&xattr_name);
233237

238+
if (probe_path_is_blocked(st_path, blocked_paths)) {
239+
return 0;
240+
}
241+
234242
char *st_path_with_prefix = oscap_path_join(prefix, st_path);
235243
do {
236244
/* estimate the size of the buffer */
@@ -441,7 +449,7 @@ int fileextendedattribute_probe_main(probe_ctx *ctx, void *mutex)
441449

442450
if ((ofts = oval_fts_open_prefixed(prefix, path, filename, filepath, behaviors, probe_ctx_getresult(ctx))) != NULL) {
443451
while ((ofts_ent = oval_fts_read(ofts)) != NULL) {
444-
file_cb(prefix, ofts_ent->path, ofts_ent->file, &cbargs, &gr_lastpath);
452+
file_cb(prefix, ofts_ent->path, ofts_ent->file, &cbargs, &gr_lastpath, ctx->blocked_paths);
445453
oval_ftsent_free(ofts_ent);
446454
}
447455
oval_fts_close(ofts);

0 commit comments

Comments
 (0)