Blame SOURCES/e2fsprogs-1.45.6-misc-fix-potential-segmentation-fault-problem-in-sca.patch

f239de
From 4a92545b8711df405dc804236d66386780696ce1 Mon Sep 17 00:00:00 2001
f239de
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
f239de
Date: Wed, 30 Jun 2021 16:27:20 +0800
f239de
Subject: [PATCH 31/46] misc: fix potential segmentation fault problem in
f239de
 scandir()
f239de
Content-Type: text/plain
f239de
f239de
In scandir(), temp_list[num_dent] is allocated by calling
f239de
malloc(), we should check whether malloc() returns NULL before
f239de
accessing temp_list[num_dent].
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
 misc/create_inode.c | 2 ++
f239de
 1 file changed, 2 insertions(+)
f239de
f239de
diff --git a/misc/create_inode.c b/misc/create_inode.c
f239de
index 6f8487b9..38f37beb 100644
f239de
--- a/misc/create_inode.c
f239de
+++ b/misc/create_inode.c
f239de
@@ -752,6 +752,8 @@ static int scandir(const char *dir_name, struct dirent ***name_list,
f239de
 		}
f239de
 		// add the copy of dirent to the list
f239de
 		temp_list[num_dent] = (struct dirent*)malloc((dent->d_reclen + 3) & ~3);
f239de
+		if (!temp_list[num_dent])
f239de
+			goto out;
f239de
 		memcpy(temp_list[num_dent], dent, dent->d_reclen);
f239de
 		num_dent++;
f239de
 	}
f239de
-- 
f239de
2.35.1
f239de