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

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