]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
argv_parse: check return value of malloc in argv_parse()
authorZhiqiang Liu <liuzhiqiang26@huawei.com>
Wed, 30 Jun 2021 08:27:19 +0000 (16:27 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 16 Jul 2021 03:41:20 +0000 (23:41 -0400)
In argv_parse(), return value of malloc should be checked
whether it is NULL, otherwise, it may cause a segfault error.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/support/argv_parse.c

index d22f6344c0142587a272244e4504eb2e0f301f96..1f50f9e57c7880b04f4c85aa1db26f5ce0cafcb9 100644 (file)
@@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
        if (argv == 0) {
                argv = malloc(sizeof(char *));
                free(buf);
+               if (!argv)
+                       return -1;
        }
        argv[argc] = 0;
        if (ret_argc)