diff mbox series

checkpolicy/fuzz: fix setjmp condition

Message ID 20241018151213.444982-1-cgoettsche@seltendoof.de (mailing list archive)
State New
Headers show
Series checkpolicy/fuzz: fix setjmp condition | expand

Commit Message

Christian Göttsche Oct. 18, 2024, 3:12 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

setjmp(3) returns 0 on the first fake invocation, adjust the condition
accordingly.

Reported by the OSS Fuzz Introspector[1].

[1]: https://storage.googleapis.com/oss-fuzz-introspector/selinux/inspector-report/20241016/fuzz_report.html

Fixes: f07fc2a75 ("checkpolicy/fuzz: override YY_FATAL_ERROR")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 checkpolicy/fuzz/checkpolicy-fuzzer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Carter Oct. 21, 2024, 5:35 p.m. UTC | #1
On Fri, Oct 18, 2024 at 11:23 AM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> setjmp(3) returns 0 on the first fake invocation, adjust the condition
> accordingly.
>
> Reported by the OSS Fuzz Introspector[1].
>
> [1]: https://storage.googleapis.com/oss-fuzz-introspector/selinux/inspector-report/20241016/fuzz_report.html
>
> Fixes: f07fc2a75 ("checkpolicy/fuzz: override YY_FATAL_ERROR")
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  checkpolicy/fuzz/checkpolicy-fuzzer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/checkpolicy/fuzz/checkpolicy-fuzzer.c b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> index ddb43260..331201c0 100644
> --- a/checkpolicy/fuzz/checkpolicy-fuzzer.c
> +++ b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> @@ -101,7 +101,7 @@ static int read_source_policy(policydb_t *p, const uint8_t *data, size_t size)
>
>         init_parser(1);
>
> -       if (!setjmp(fuzzing_pre_parse_stack_state)) {
> +       if (setjmp(fuzzing_pre_parse_stack_state) != 0) {
>                 queue_destroy(id_queue);
>                 fclose(yyin);
>                 yylex_destroy();
> --
> 2.45.2
>
>
diff mbox series

Patch

diff --git a/checkpolicy/fuzz/checkpolicy-fuzzer.c b/checkpolicy/fuzz/checkpolicy-fuzzer.c
index ddb43260..331201c0 100644
--- a/checkpolicy/fuzz/checkpolicy-fuzzer.c
+++ b/checkpolicy/fuzz/checkpolicy-fuzzer.c
@@ -101,7 +101,7 @@  static int read_source_policy(policydb_t *p, const uint8_t *data, size_t size)
 
 	init_parser(1);
 
-	if (!setjmp(fuzzing_pre_parse_stack_state)) {
+	if (setjmp(fuzzing_pre_parse_stack_state) != 0) {
 		queue_destroy(id_queue);
 		fclose(yyin);
 		yylex_destroy();