summaryrefslogtreecommitdiff
path: root/src/mediactl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mediactl.c')
-rw-r--r--src/mediactl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mediactl.c b/src/mediactl.c
index 5b8c587..bc6a713 100644
--- a/src/mediactl.c
+++ b/src/mediactl.c
@@ -63,10 +63,17 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
{
unsigned int i;
+ /* A match is impossible if the entity name is longer than the maximum
+ * size we can get from the kernel.
+ */
+ if (length >= FIELD_SIZEOF(struct media_entity_desc, name))
+ return NULL;
+
for (i = 0; i < media->entities_count; ++i) {
struct media_entity *entity = &media->entities[i];
- if (strncmp(entity->info.name, name, length) == 0)
+ if (strncmp(entity->info.name, name, length) == 0 &&
+ entity->info.name[length] == '\0')
return entity;
}