Blame SOURCES/e2fsprogs-1.45.6-ext2ed-fix-potential-NULL-pointer-dereference-in-dup.patch

a77133
From c0a66f76f9c5b2ed0c2f20d1b59b4715f10a60f7 Mon Sep 17 00:00:00 2001
a77133
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Date: Wed, 30 Jun 2021 16:27:24 +0800
a77133
Subject: [PATCH 33/46] ext2ed: fix potential NULL pointer dereference in
a77133
 dupstr()
a77133
Content-Type: text/plain
a77133
a77133
In dupstr(), we should check return value of malloc().
a77133
a77133
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
a77133
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
a77133
Reviewed-by: Wu Bo <wubo40@huawei.com>
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 ext2ed/main.c | 2 ++
a77133
 1 file changed, 2 insertions(+)
a77133
a77133
diff --git a/ext2ed/main.c b/ext2ed/main.c
a77133
index f7e7d7df..9d33a8e1 100644
a77133
--- a/ext2ed/main.c
a77133
+++ b/ext2ed/main.c
a77133
@@ -524,6 +524,8 @@ char *dupstr (char *src)
a77133
 	char *ptr;
a77133
 
a77133
 	ptr=(char *) malloc (strlen (src)+1);
a77133
+	if (!ptr)
a77133
+		return NULL;
a77133
 	strcpy (ptr,src);
a77133
 	return (ptr);
a77133
 }
a77133
-- 
a77133
2.35.1
a77133