From 1d9a00a66f98747af74befe0e4c3338924479284 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 6 Jun 2024 16:25:24 +0200 Subject: [PATCH] v4l2: fix string size vendor_id and product_id are encoded as 0xHHHH and so it needs 7 chars with the 0. See #4034 --- spa/plugins/v4l2/v4l2-device.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spa/plugins/v4l2/v4l2-device.c b/spa/plugins/v4l2/v4l2-device.c index 586578d82..2379d2105 100644 --- a/spa/plugins/v4l2/v4l2-device.c +++ b/spa/plugins/v4l2/v4l2-device.c @@ -32,8 +32,8 @@ static const char default_device[] = "/dev/video0"; struct props { char device[64]; char devnum[32]; - char product_id[6]; - char vendor_id[6]; + char product_id[7]; + char vendor_id[7]; int device_fd; }; @@ -244,13 +244,13 @@ impl_init(const struct spa_handle_factory *factory, reset_props(&this->props); if (info && (str = spa_dict_lookup(info, SPA_KEY_API_V4L2_PATH))) - strncpy(this->props.device, str, 63); + strncpy(this->props.device, str, sizeof(this->props.device)-1); if (info && (str = spa_dict_lookup(info, SPA_KEY_DEVICE_DEVIDS))) - strncpy(this->props.devnum, str, 31); + strncpy(this->props.devnum, str, sizeof(this->props.devnum)-1); if (info && (str = spa_dict_lookup(info, SPA_KEY_DEVICE_PRODUCT_ID))) - strncpy(this->props.product_id, str, 5); + strncpy(this->props.product_id, str, sizeof(this->props.product_id)-1); if (info && (str = spa_dict_lookup(info, SPA_KEY_DEVICE_VENDOR_ID))) - strncpy(this->props.vendor_id, str, 5); + strncpy(this->props.vendor_id, str, sizeof(this->props.vendor_id)-1); return 0; }