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 <archer_ame@yahoo.co.jp> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>main
parent
44f220ad62
commit
4ecd1ef010
|
@ -61,7 +61,7 @@ LT_PREREQ([2.2])
|
||||||
LT_INIT([disable-static])
|
LT_INIT([disable-static])
|
||||||
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
|
|
||||||
AC_SUBST(PTHREADSTUBS_CFLAGS)
|
AC_SUBST(PTHREADSTUBS_CFLAGS)
|
||||||
AC_SUBST(PTHREADSTUBS_LIBS)
|
AC_SUBST(PTHREADSTUBS_LIBS)
|
||||||
|
|
||||||
|
|
|
@ -2929,11 +2929,11 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
ret = read(fd, data, sizeof(data));
|
ret = read(fd, data, sizeof(data)-1);
|
||||||
data[sizeof(data)-1] = '\0';
|
|
||||||
close(fd);
|
close(fd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
data[ret] = '\0';
|
||||||
|
|
||||||
#define TAG "PCI_SLOT_NAME="
|
#define TAG "PCI_SLOT_NAME="
|
||||||
str = strstr(data, TAG);
|
str = strstr(data, TAG);
|
||||||
|
|
Loading…
Reference in New Issue