]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2ed: fix potential NULL pointer dereference in dupstr()
authorZhiqiang Liu <liuzhiqiang26@huawei.com>
Wed, 30 Jun 2021 08:27:24 +0000 (16:27 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 16 Jul 2021 03:59:21 +0000 (23:59 -0400)
In dupstr(), we should check return value of malloc().

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
ext2ed/main.c

index f7e7d7dfae8f054504cb8fb7bf8a14475f3c65f9..9d33a8e1afe610b7a71c961cd50c204d5aebc7c1 100644 (file)
@@ -524,6 +524,8 @@ char *dupstr (char *src)
        char *ptr;
 
        ptr=(char *) malloc (strlen (src)+1);
+       if (!ptr)
+               return NULL;
        strcpy (ptr,src);
        return (ptr);
 }