All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: Allow NULL buffer in dm_copy_name_and_uuid if only one vaule requested.
@ 2008-12-17 12:02 Milan Broz
  0 siblings, 0 replies; only message in thread
From: Milan Broz @ 2008-12-17 12:02 UTC (permalink / raw)
  To: device-mapper development; +Cc: Alasdair G Kergon

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-17 12:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-17 12:02 [PATCH] dm: Allow NULL buffer in dm_copy_name_and_uuid if only one vaule requested Milan Broz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.