Explorar el Código

Linux: Include the null byte in joystick path

This potential bug was found thanks to gcc 8’s -Wstringop-truncation
warning.
Emmanuel Gil Peyrot hace 7 años
padre
commit
e75af5f531
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      src/linux_joystick.c

+ 1 - 1
src/linux_joystick.c

@@ -228,7 +228,7 @@ static GLFWbool openJoystickDevice(const char* path)
         return GLFW_FALSE;
         return GLFW_FALSE;
     }
     }
 
 
-    strncpy(linjs.path, path, sizeof(linjs.path));
+    strncpy(linjs.path, path, sizeof(linjs.path) - 1);
     memcpy(&js->linjs, &linjs, sizeof(linjs));
     memcpy(&js->linjs, &linjs, sizeof(linjs));
 
 
     pollAbsState(js);
     pollAbsState(js);