From: Laurent Pinchart Date: Thu, 17 Jul 2014 11:52:08 +0000 (-0300) Subject: [media] media: Use strlcpy instead of custom code X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=de8eae36057b50086278af1ec4d96fc9a2e35f0b;p=openwrt%2Fstaging%2Fblogic.git [media] media: Use strlcpy instead of custom code Replace strncpy + manually setting the terminating '\0' with an strlcpy call. Reported-by: Joe Perches Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 73a432934bd8..7b39440192d6 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -103,10 +103,8 @@ static long media_device_enum_entities(struct media_device *mdev, return -EINVAL; u_ent.id = ent->id; - if (ent->name) { - strncpy(u_ent.name, ent->name, sizeof(u_ent.name)); - u_ent.name[sizeof(u_ent.name) - 1] = '\0'; - } + if (ent->name) + strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); u_ent.type = ent->type; u_ent.revision = ent->revision; u_ent.flags = ent->flags;