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

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