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

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