[dm-devel] [PATCH 3/8] libmultipath, alloc_path_with_pathinfo(): Ensure that pp->wwid is '\0'-terminated

Martin Wilck mwilck at suse.com
Wed Mar 7 23:15:46 UTC 2018


From: Bart Van Assche <bart.vanassche at wdc.com>

Discovered by Coverity (CID 173257).

Signed-off-by: Bart Van Assche <bart.vanassche at wdc.com>
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 libmultipath/discovery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 9efcaac81dc1..71c75872c937 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -53,8 +53,8 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
 	if (!pp)
 		return PATHINFO_FAILED;
 
-	if(wwid)
-		strncpy(pp->wwid, wwid, sizeof(pp->wwid));
+	if (wwid)
+		strlcpy(pp->wwid, wwid, sizeof(pp->wwid));
 
 	if (safe_sprintf(pp->dev, "%s", devname)) {
 		condlog(0, "pp->dev too small");
-- 
2.16.1




More information about the dm-devel mailing list