Skip to content

Commit

Permalink
[media] media: info leak in media_device_enum_entities()
Browse files Browse the repository at this point in the history
The last part of the "u_ent.name" buffer isn't cleared so it still has
uninitialized stack memory.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Apr 23, 2013
1 parent 59501bb commit c06ca8f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/media/media-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ static long media_device_enum_entities(struct media_device *mdev,
return -EINVAL;

u_ent.id = ent->id;
u_ent.name[0] = '\0';
if (ent->name)
strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
if (ent->name) {
strncpy(u_ent.name, ent->name, sizeof(u_ent.name));
u_ent.name[sizeof(u_ent.name) - 1] = '\0';
} else {
memset(u_ent.name, 0, 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 c06ca8f

Please sign in to comment.