[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]