2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-05 00:35:14 +00:00

Implement sudoers_policy_deregister_hooks()

Register/deregister hooks in fuzz_policy and also call show_version().
This commit is contained in:
Todd C. Miller
2021-02-25 15:02:09 -07:00
parent e6dc13229f
commit b3b80fe6df
3 changed files with 31 additions and 2 deletions

View File

@@ -134,6 +134,12 @@ fuzz_printf(int msg_type, const char *fmt, ...)
return 0;
}
int
fuzz_hook_stub(struct sudo_hook *hook)
{
return 0;
}
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
@@ -270,6 +276,8 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
free(line);
line = NULL;
sudoers_policy.register_hooks(SUDO_API_VERSION, fuzz_hook_stub);
for (i = 0; i < num_checks; i++) {
/* Call policy open function */
res = sudoers_policy.open(SUDO_API_VERSION, fuzz_conversation, fuzz_printf,
@@ -279,6 +287,9 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
switch (res) {
case 1:
/* success */
if (i == 0)
sudoers_policy.show_version(true);
if (argv.len == 0) {
/* Must have a command to check. */
push(&argv, "/usr/bin/id");
@@ -318,6 +329,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
env_init(NULL);
}
sudoers_policy.deregister_hooks(SUDO_API_VERSION, fuzz_hook_stub);
sudoers_gc_run();
free_dynamic_array(&plugin_args);