[igt-dev] [PATCH i-g-t v3] tests/testdisplay: fix heap overflow

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 20 12:00:13 UTC 2019


Quoting Simon Ser (2019-03-20 11:48:57)
> +       argv0 = strdup(argv[0]);
> +       igt_assert(argv0);
> +       exec_path = dirname(argv0);
>         ret = chdir(exec_path);
>         igt_assert_eq(ret, 0);

One should ask Petri if igt_assert_eq() is even legal inside the helper
(i.e. outside of igt_main and igt_subtest).

> -       free(exec_path);
> +       free(argv0);

Ok, looks like dirname(e) doesn't die with NULL.

>  }
>  
>  static void restore_termio_mode(int sig)
> @@ -626,7 +620,7 @@ int main(int argc, char **argv)
>  
>         igt_skip_on_simulation();
>  
> -       enter_exec_path( argv );
> +       enter_exec_path((const char **) argv);

Sigh, I forget about C being unhelpful.

Your call whether that cast is worth it.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list