Blame SOURCES/0002-Ensure-the-device-name-is-null-terminated.patch

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