]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
[media] media: info leak in media_device_enum_entities()
authorDan Carpenter <dan.carpenter@oracle.com>
Sun, 21 Apr 2013 10:10:03 +0000 (07:10 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 23 Apr 2013 19:58:52 +0000 (16:58 -0300)
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>
drivers/media/media-device.c

index 99b80b6f7f67a477fcaf9192b9a273688ae11ca0..1957c0df08fdb5717acedbf17162774f8c75dd05 100644 (file)
@@ -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;