[dm-devel] [PATCH 47/57] libmultipath: sanity check on store_path()

Hannes Reinecke hare at suse.de
Wed Apr 27 11:10:48 UTC 2016


If a path has neither pp->dev nor pp->dev_t set we cannot
identify the path at all.
So reject any path where this is not the case.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 libmultipath/structs.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 39b2e05..937e4a2 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -283,6 +283,20 @@ free_multipathvec (vector mpvec, enum free_path_mode free_paths)
 int
 store_path (vector pathvec, struct path * pp)
 {
+	int err = 0;
+
+	if (!strlen(pp->dev_t)) {
+		condlog(2, "%s: Empty device number", pp->dev);
+		err++;
+	}
+	if (!strlen(pp->dev)) {
+		condlog(2, "%s: Empty device name", pp->dev_t);
+		err++;
+	}
+
+	if (err > 1)
+		return 1;
+
 	if (!vector_alloc_slot(pathvec))
 		return 1;
 
-- 
2.6.6




More information about the dm-devel mailing list