Skip to content

Commit

Permalink
[media] media: Use strlcpy instead of custom code
Browse files Browse the repository at this point in the history
Replace strncpy + manually setting the terminating '\0' with an strlcpy
call.

Reported-by: Joe Perches <[email protected]>
Signed-off-by: Laurent Pinchart <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
pinchartl authored and mchehab committed Sep 21, 2014
1 parent 62ea864 commit de8eae3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/media/media-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit de8eae3

Please sign in to comment.