Skip to contentSkip to conversation

dm: replace strncpy() with strscpy()

PATCH New Miles Chen 1 participant 1 message May 15, 2020

Subsystems (2)
lore
Share & tools
lore

Miles Chen

author
#0 lore raw

PATCH 1/1 dm: replace strncpy() with strscpy()

Replace strncpy() with strscpy() to guarantee a NULL-terminated string.

Detected by Coverity.

---
 drivers/md/dm-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-ioctl.c +1 -1
index ac83f5002ce5..4dc3658e3351 100644
@@ -1167,7 +1167,7 @@ static void retrieve_status(struct dm_table *table,
 		spec->status = 0;
 		spec->sector_start = ti->begin;
 		spec->length = ti->len;
-		strncpy(spec->target_type, ti->type->name,
+		strscpy(spec->target_type, ti->type->name,
 			sizeof(spec->target_type));
 
 		outptr += sizeof(struct dm_target_spec);
Signature · 1 line
2.18.0