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

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

 



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


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux