Ensure the device name is null-terminated

This commit is contained in:
lingsheng 2024-08-01 06:37:00 +00:00
parent c8c06c23b5
commit 188c9b3082
3 changed files with 50 additions and 2 deletions

View File

@ -0,0 +1,43 @@
From a020fda02fd0aca0c53b2368e6602bbd12002936 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 8 Oct 2018 12:55:57 +1000
Subject: [PATCH] Ensure the device name is null-terminated
And expand the size to 18, because the stack array we copied this into is 18
bytes long. This covers us for up to 999 (kernel) v4l devices and that is
definitely not a reason to use the "640k ought to be enough" meme.
Found by - you guessed it - coverity!
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
---
src/v4l.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/v4l.c b/src/v4l.c
index 0f1058e..583c7b8 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -188,7 +188,7 @@ static const XF86AttributeRec FreqAttr =
static struct V4L_DEVICE {
int fd;
int useCount;
- char devName[16];
+ char devName[18];
} v4l_devices[MAX_V4L_DEVICES] = {
{ -1 },
{ -1 },
@@ -1157,7 +1157,8 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
}
xf86Msg(X_INFO, "v4l: enabling overlay mode for %s.\n", dev);
- strncpy(V4L_NAME, dev, 16);
+ strncpy(V4L_NAME, dev, 18);
+ V4L_NAME[17] = '\0';
V4LBuildEncodings(pPPriv, fd);
if (NULL == pPPriv->enc)
return FALSE;
--
2.33.0

View File

@ -4,12 +4,14 @@
Name: xorg-x11-drv-v4l Name: xorg-x11-drv-v4l
Version: 0.3.0 Version: 0.3.0
Release: 2 Release: 3
License: MIT License: MIT
Summary: Xorg X11 v4l video driver Summary: Xorg X11 v4l video driver
URL: https://www.x.org URL: https://www.x.org
Source0: https://www.x.org/pub/individual/driver/xf86-video-v4l-%{version}.tar.bz2 Source0: https://www.x.org/pub/individual/driver/xf86-video-v4l-%{version}.tar.bz2
Patch0: backport-Ensure-the-device-name-is-null-terminated.patch
BuildRequires: xorg-x11-server-devel >= 1.10.99.902 BuildRequires: xorg-x11-server-devel >= 1.10.99.902
BuildRequires: autoconf automake libtool BuildRequires: autoconf automake libtool
@ -44,6 +46,9 @@ make
%{_mandir}/man4/v4l.4* %{_mandir}/man4/v4l.4*
%changelog %changelog
* Thu Aug 01 2024 lingsheng <lingsheng1@h-partners.com> - 0.3.0-3
- Ensure the device name is null-terminated
* Tue Oct 25 2022 wangkerong <wangkerong@h-partners.com> - 0.3.0-2 * Tue Oct 25 2022 wangkerong <wangkerong@h-partners.com> - 0.3.0-2
- rebuild for next release - rebuild for next release

View File

@ -1,4 +1,4 @@
version_control: git version_control: git
src_repo: https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l.git src_repo: https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l.git
tag_prefix: ^xf86-video-v4l- tag_prefix: ^xf86-video-v4l-
seperator: . separator: .