From: Michal MalĂ˝ Date: Wed, 8 Jul 2015 16:45:55 +0000 (+0200) Subject: Make sure that the deviceName char array is always zero-terminated. X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=f9b28d71d0d44e94ee2231119b35046ea818c489;p=FFBChecker.git Make sure that the deviceName char array is always zero-terminated. --- 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