[PATCH] mdadm/Monitor:triggers core dump when stat2devnm return NULL

DORMANTno replies REVIEWED: 1 (0M)

From: Zhilong Liu <hidden>
Date: 2017-03-20 05:21:41
Subsystem: the rest · Maintainer: Linus Torvalds

1 review trailer.

Monitor: ensure that the device should be a block
device when uses --wait parameter, such as the 'f'
and 'd' type file would be triggered core dumped.
such as: ./mdadm --wait /dev/md/

Reviewed-by: NeilBrown <redacted>
Signed-off-by: Zhilong Liu <redacted>
---
 Monitor.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Monitor.c b/Monitor.c
index 802a9d9..f8850d3 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1002,7 +1002,12 @@ int Wait(char *dev)
 			strerror(errno));
 		return 2;
 	}
-	strcpy(devnm, stat2devnm(&stb));
+	char *tmp = stat2devnm(&stb);
+	if (!tmp) {
+		pr_err("%s is not a block device.\n", dev);
+		return 2;
+	}
+	strcpy(devnm, tmp);
 
 	while(1) {
 		struct mdstat_ent *ms = mdstat_read(1, 0);
-- 
2.6.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help