From f9b28d71d0d44e94ee2231119b35046ea818c489 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 8 Jul 2015 18:45:55 +0200 Subject: [PATCH] Make sure that the deviceName char array is always zero-terminated. --- deviceprober.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deviceprober.cpp b/deviceprober.cpp index 541129e..b486833 100644 --- a/deviceprober.cpp +++ b/deviceprober.cpp @@ -18,13 +18,14 @@ DeviceProber::DeviceProber(QObject* parent) : DeviceProber::DeviceList DeviceProber::listDevices() { DeviceProber::DeviceList list; + char deviceName[64]; QDir devDir(DEVICE_NODES_PATH); //QStringList devices = DeviceProber::s_deviceNodesPath.entryList(QDir::NoDotAndDotDot); QStringList devices = devDir.entryList(QDir::System); + deviceName[63] = '\0'; for (const QString& d : devices) { int fd, ret; - char deviceName[64]; DeviceInfo dinfo; QString devicePath = devDir.absoluteFilePath(d); @@ -35,7 +36,7 @@ DeviceProber::DeviceList DeviceProber::listDevices() } dinfo.path = devicePath; - ret = ioctl(fd, EVIOCGNAME(64), deviceName); + ret = ioctl(fd, EVIOCGNAME(63), deviceName); if (ret < 0) qDebug() << "Cannot get name of device" << d << strerror(errno); else -- 2.43.5