aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhiqiang Liu <liuzhiqiang26@huawei.com>2021-07-28 09:56:48 +0800
committerTheodore Ts'o <tytso@mit.edu>2021-08-02 22:35:02 -0400
commitc8e9e0135b3eb0d8a18387d58645e7cc1062da58 (patch)
treed0dbd53fe4d11d0be6e41ce75828c7dc582b1961
parent212827d1909d66f57bb76524c18c113d6bc71909 (diff)
downloade2fsprogs-c8e9e0135b3eb0d8a18387d58645e7cc1062da58.tar.gz
lsattr: check whether path is NULL in lsattr_dir_proc()
In lsattr_dir_proc(), if malloc() return NULL, it will cause a segmentation fault problem. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--misc/lsattr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/misc/lsattr.c b/misc/lsattr.c
index 0d9543762..55080e92a 100644
--- a/misc/lsattr.c
+++ b/misc/lsattr.c
@@ -144,6 +144,11 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de,
int dir_len = strlen(dir_name);
path = malloc(dir_len + strlen (de->d_name) + 2);
+ if (!path) {
+ fputs(_("Couldn't allocate path variable in lsattr_dir_proc\n"),
+ stderr);
+ return -1;
+ }
if (dir_len && dir_name[dir_len-1] == '/')
sprintf (path, "%s%s", dir_name, de->d_name);