[dm-devel] [PATCH] dm: Allow NULL buffer in dm_copy_name_and_uuid if only one vaule requested.

Milan Broz mbroz at redhat.com
Wed Dec 17 12:02:18 UTC 2008


Allow NULL buffer in dm_copy_name_and_uuid if only one value requested.

Also add maximal length check for string size.

(This patch is needed for device-mapper sysfs extension.)

Signed-off-by: Milan Broz <mbroz at redhat.com>
---
 drivers/md/dm-ioctl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 7c3ae49..59b3283 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1548,8 +1548,10 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
 		goto out;
 	}
 
-	strcpy(name, hc->name);
-	strcpy(uuid, hc->uuid ? : "");
+	if (name)
+		strncpy(name, hc->name, DM_NAME_LEN);
+	if (uuid)
+		strncpy(uuid, hc->uuid ? : "", DM_UUID_LEN);
 
 out:
 	up_read(&_hash_lock);





More information about the dm-devel mailing list