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

Chris Wilson
2019-03-20T12:00:29Z

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@chris-wilson.co.uk>
-Chris