drm: Branch 'master'

[email protected] (Emil Velikov)
Newsgroups gmane.comp.video.dri.patches
Message-ID <[email protected]>
 configure.ac |    2 +-
 xf86drm.c    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4ecd1ef010beadef05f7c63c4546849b2eb5ac15
Author: Taro Yamada <[email protected]>
Date:   Tue Dec 13 20:18:28 2016 +0900

    xf86drm: fix null termination of string buffer
    
    The string written to the buffer by read() is not null-terminated,
    but currently drmParsePciBusInfo() places null character only at the end of the buffer, not at the end of the
    string.
    As a result, the string passed to sscanf() contains an uninitialized value.
    
    This patch changes to places null character at the end of the string.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99045
    Signed-off-by: Taro Yamada <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>

diff --git a/configure.ac b/configure.ac
index e0597c3..39973b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ LT_PREREQ([2.2])
 LT_INIT([disable-static])
 
 
-PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
+
 AC_SUBST(PTHREADSTUBS_CFLAGS)
 AC_SUBST(PTHREADSTUBS_LIBS)
 
diff --git a/xf86drm.c b/xf86drm.c
index b8b2cfe..7b78dc6 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2929,11 +2929,11 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
     if (fd < 0)
         return -errno;
 
-    ret = read(fd, data, sizeof(data));
-    data[sizeof(data)-1] = '\0';
+    ret = read(fd, data, sizeof(data)-1);
     close(fd);
     if (ret < 0)
         return -errno;
+    data[ret] = '\0';
 
 #define TAG "PCI_SLOT_NAME="
     str = strstr(data, TAG);

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.