Skip to content

Commit

Permalink
DO NOT MERGE [WIP]
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
  • Loading branch information
cgzones committed Jun 15, 2022
1 parent 17b9687 commit 725559a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ cscope.*
.*.swp
# Failsafes
!.gitignore

corpus_dir/
out/
DESTDIR/
fuzz-*.log
15 changes: 15 additions & 0 deletions checkpolicy/fuzz/checkpolicy-fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ static int read_source_policy(policydb_t *p, const uint8_t *data, size_t size)
return 0;
}

static int check_level(hashtab_key_t key, hashtab_datum_t datum, void *arg __attribute__ ((unused)))
{
level_datum_t *levdatum = (level_datum_t *) datum;

if (!levdatum->isalias && !levdatum->defined) {
fprintf(stderr,
"Error: sensitivity %s was not used in a level definition!\n",
key);
abort();
}
return 0;
}

static int write_binary_policy(policydb_t *p, FILE *outfp)
{
struct policy_file pf;
Expand Down Expand Up @@ -149,6 +162,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (read_source_policy(&parsepolicydb, data, size))
goto exit;

(void) hashtab_map(parsepolicydb.p_levels.table, check_level, NULL);

if (hierarchy_check_constraints(NULL, &parsepolicydb))
goto exit;

Expand Down

0 comments on commit 725559a

Please sign in to comment.