Blame SOURCES/e2fsprogs-1.45.6-argv_parse-check-return-value-of-malloc-in-argv_pars.patch

a77133
From 9e298ba470a6abc7d94fe659cf65fcb0b993c0b8 Mon Sep 17 00:00:00 2001
a77133
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Date: Wed, 30 Jun 2021 16:27:19 +0800
a77133
Subject: [PATCH 30/46] argv_parse: check return value of malloc in
a77133
 argv_parse()
a77133
Content-Type: text/plain
a77133
a77133
In argv_parse(), return value of malloc should be checked
a77133
whether it is NULL, otherwise, it may cause a segfault error.
a77133
a77133
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 lib/support/argv_parse.c | 2 ++
a77133
 1 file changed, 2 insertions(+)
a77133
a77133
diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c
a77133
index d22f6344..1f50f9e5 100644
a77133
--- a/lib/support/argv_parse.c
a77133
+++ b/lib/support/argv_parse.c
a77133
@@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
a77133
 	if (argv == 0) {
a77133
 		argv = malloc(sizeof(char *));
a77133
 		free(buf);
a77133
+		if (!argv)
a77133
+			return -1;
a77133
 	}
a77133
 	argv[argc] = 0;
a77133
 	if (ret_argc)
a77133
-- 
a77133
2.35.1
a77133