Skip to contentSkip to conversation

dm: strncpy does not null terminate string

PATCH New [email protected] 1 participant 1 message Sep 18, 2009 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 dm: strncpy does not null terminate string

From: Roel Kluin <[email protected]>

strlcpy() will always null terminate the string.

---

 drivers/md/dm-ioctl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c renamed from drivers/md/dm-ioctl.c~dm-strncpy-does-not-null-terminate-string +2 -2
diff -puN drivers/md/dm-ioctl.c~dm-strncpy-does-not-null-terminate-string drivers/md/dm-ioctl.c
@@ -634,9 +634,9 @@ static struct mapped_device *find_device
 		 * Sneakily write in both the name and the uuid
 		 * while we have the cell.
 		 */
-		strncpy(param->name, hc->name, sizeof(param->name));
+		strlcpy(param->name, hc->name, sizeof(param->name));
 		if (hc->uuid)
-			strncpy(param->uuid, hc->uuid, sizeof(param->uuid)-1);
+			strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
 		else
 			param->uuid[0] = '\0';
 

_