lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <20210630082724.50838-9-wuguanghao3@huawei.com> Date: Wed, 30 Jun 2021 16:27:20 +0800 From: wuguanghao <wuguanghao3@...wei.com> To: <linux-ext4@...r.kernel.org>, <artem.blagodarenko@...il.com> CC: <liuzhiqiang26@...wei.com>, <linfeilong@...wei.com>, <wuguanghao3@...wei.com> Subject: [PATCH v2 08/12] misc: fix potential segmentation fault problem in scandir() From: Zhiqiang Liu <liuzhiqiang26@...wei.com> In scandir(), temp_list[num_dent] is allocated by calling malloc(), we should check whether malloc() returns NULL before accessing temp_list[num_dent]. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com> Signed-off-by: Wu Guanghao <wuguanghao3@...wei.com> --- misc/create_inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/create_inode.c b/misc/create_inode.c index d62e1cb4..869b0614 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -771,6 +771,9 @@ static int scandir(const char *dir_name, struct dirent ***name_list, } // add the copy of dirent to the list temp_list[num_dent] = (struct dirent*)malloc((dent->d_reclen + 3) & ~3); + if (!temp_list[num_dent]) { + goto out; + } memcpy(temp_list[num_dent], dent, dent->d_reclen); num_dent++; } -- 2.19.1
Powered by blists - more mailing lists