diff options
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r-- | libavdevice/v4l2.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index fefea54142..2ecfb9fae7 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -1033,13 +1033,19 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l while ((entry = readdir(dir))) { AVDeviceInfo *device = NULL; struct v4l2_capability cap; - int fd = -1; + int fd = -1, size; char device_name[256]; if (!v4l2_is_v4l_dev(entry->d_name)) continue; - snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); + size = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); + if (size >= sizeof(device_name)) { + av_log(ctx, AV_LOG_ERROR, "Device name too long.\n"); + ret = AVERROR(ENOSYS); + break; + } + if ((fd = device_open(ctx, device_name)) < 0) continue; |