fix array out of bounds bug in evdev

This commit is contained in:
Krylov Yaroslav 2019-06-24 11:56:39 +03:00
parent b004d0514e
commit e3f1c47623

View File

@ -283,7 +283,7 @@ static void updateMods()
_GLFWeventDevice* ed = NULL; _GLFWeventDevice* ed = NULL;
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
ed = _glfw.evdev.devices + edid; ed = _glfw.evdev.devices + edid;
if (ed->present){ if (ed->present){
@ -428,7 +428,7 @@ static GLFWbool openEventDevice(const char* path)
char name[256] = ""; char name[256] = "";
_GLFWeventDevice* ed = NULL; _GLFWeventDevice* ed = NULL;
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
if (!_glfw.evdev.devices[edid].present) if (!_glfw.evdev.devices[edid].present)
continue; continue;
@ -436,7 +436,7 @@ static GLFWbool openEventDevice(const char* path)
return GLFW_FALSE; return GLFW_FALSE;
} }
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
if (!_glfw.evdev.devices[edid].present) if (!_glfw.evdev.devices[edid].present)
break; break;
@ -536,7 +536,7 @@ void _glfwTerminateEvdev()
{ {
int edid; int edid;
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
_GLFWeventDevice* ed = _glfw.evdev.devices + edid; _GLFWeventDevice* ed = _glfw.evdev.devices + edid;
if (ed->present) if (ed->present)
@ -584,7 +584,7 @@ void _glfwDetectEvdevConnection()
else if (e->mask & IN_DELETE) else if (e->mask & IN_DELETE)
{ {
int edid; int edid;
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
if (strcmp(_glfw.evdev.devices[edid].path, path) == 0) if (strcmp(_glfw.evdev.devices[edid].path, path) == 0)
{ {
@ -651,7 +651,7 @@ void _glfwPollEvdevDevices()
int edid; int edid;
_GLFWeventDevice* ed = NULL; _GLFWeventDevice* ed = NULL;
for (edid = 0; edid <= GLFW_EVENT_DEVICES_MAX; edid++) for (edid = 0; edid < GLFW_EVENT_DEVICES_MAX; edid++)
{ {
ed = _glfw.evdev.devices + edid; ed = _glfw.evdev.devices + edid;
if (ed->present) if (ed->present)