aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-12-10 18:52:07 -0500
committerAlasdair G Kergon <agk@redhat.com>2009-12-10 18:52:07 -0500
commita518b86d0b1b6a474f154697dc6f33e0a317ae72 (patch)
tree759b2ddb2a6a7f3745ee88d817652de5568da509
parent5339fc2d47d1d720e027b9b832bf5aae8fba2ac0 (diff)
dm ioctl: prefer strlcpy over strncpy
strlcpy() will always null terminate the string. The code should already guarantee this as the last bytes are already NULs and the string lengths were restricted before being stored in hc. Removing the '-1' becomes necessary so strlcpy() doesn't lose the last character of a maximum-length string. - agk Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-ioctl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d19854c9818..99de0e4ce83 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -645,9 +645,9 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
645 * Sneakily write in both the name and the uuid 645 * Sneakily write in both the name and the uuid
646 * while we have the cell. 646 * while we have the cell.
647 */ 647 */
648 strncpy(param->name, hc->name, sizeof(param->name)); 648 strlcpy(param->name, hc->name, sizeof(param->name));
649 if (hc->uuid) 649 if (hc->uuid)
650 strncpy(param->uuid, hc->uuid, sizeof(param->uuid)-1); 650 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
651 else 651 else
652 param->uuid[0] = '\0'; 652 param->uuid[0] = '\0';
653 653