[CRIU] [PATCH 1/2] zdtm:mnt_ext_auto: avoid segfault if ZDTM_NEWNS is not set
Andrei Vagin
avagin at virtuozzo.com
Fri Nov 18 16:42:57 PST 2016
On Fri, Nov 18, 2016 at 12:05:11PM +0300, Dmitrii Shcherbakov wrote:
> If getenv returns a null pointer we get a segfault here.
>
> Let's exit in a more sane way.
>
> Signed-off-by: Dmitrii Shcherbakov <dshcherbakov at virtuozzo.com>
> ---
> test/zdtm/static/mnt_ext_auto.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/zdtm/static/mnt_ext_auto.c b/test/zdtm/static/mnt_ext_auto.c
> index c361b97..27b3faa 100644
> --- a/test/zdtm/static/mnt_ext_auto.c
> +++ b/test/zdtm/static/mnt_ext_auto.c
> @@ -37,8 +37,13 @@ int main(int argc, char ** argv)
>
> sprintf(dst, "%s/%s", get_current_dir_name(), dirname);
>
> - if (strcmp(getenv("ZDTM_NEWNS"), "1"))
> + char* zdtm_newns = getenv("ZDTM_NEWNS");
All variables have to be declared at the beginning of the function.
> + if (!zdtm_newns) {
> + pr_perror("ZDTM_NEWNS is not set");
> + return 1;
> + } else if (strcmp(zdtm_newns, "1")) {
> goto test;
> + }
>
> mkdir(dname, 755);
> sprintf(src, "%s/%s", dname, DDIR);
> --
> 2.7.4
>
More information about the CRIU
mailing list