From 188c9b3082dc747dbfb3c7d49655769119523aa3 Mon Sep 17 00:00:00 2001 From: lingsheng <860373352@qq.com> Date: Thu, 1 Aug 2024 06:37:00 +0000 Subject: [PATCH] Ensure the device name is null-terminated --- ...e-the-device-name-is-null-terminated.patch | 43 +++++++++++++++++++ xorg-x11-drv-v4l.spec | 7 ++- xorg-x11-drv-v4l.yaml | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 backport-Ensure-the-device-name-is-null-terminated.patch diff --git a/backport-Ensure-the-device-name-is-null-terminated.patch b/backport-Ensure-the-device-name-is-null-terminated.patch new file mode 100644 index 0000000..b29f9c0 --- /dev/null +++ b/backport-Ensure-the-device-name-is-null-terminated.patch @@ -0,0 +1,43 @@ +From a020fda02fd0aca0c53b2368e6602bbd12002936 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +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 +Reviewed-by: Dave Airlie +--- + 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 + diff --git a/xorg-x11-drv-v4l.spec b/xorg-x11-drv-v4l.spec index cfd3245..b22bcc4 100644 --- a/xorg-x11-drv-v4l.spec +++ b/xorg-x11-drv-v4l.spec @@ -4,12 +4,14 @@ Name: xorg-x11-drv-v4l Version: 0.3.0 -Release: 2 +Release: 3 License: MIT Summary: Xorg X11 v4l video driver URL: https://www.x.org 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: autoconf automake libtool @@ -44,6 +46,9 @@ make %{_mandir}/man4/v4l.4* %changelog +* Thu Aug 01 2024 lingsheng - 0.3.0-3 +- Ensure the device name is null-terminated + * Tue Oct 25 2022 wangkerong - 0.3.0-2 - rebuild for next release diff --git a/xorg-x11-drv-v4l.yaml b/xorg-x11-drv-v4l.yaml index 317f775..a2a97f0 100644 --- a/xorg-x11-drv-v4l.yaml +++ b/xorg-x11-drv-v4l.yaml @@ -1,4 +1,4 @@ version_control: git src_repo: https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l.git tag_prefix: ^xf86-video-v4l- -seperator: . +separator: .