瀏覽代碼

Linux: Include the null byte in joystick path

This potential bug was found thanks to gcc 8’s -Wstringop-truncation
warning.
Emmanuel Gil Peyrot 7 年之前
父節點
當前提交
e75af5f531
共有 1 個文件被更改,包括 1 次插入1 次删除
  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;
     }
 
-    strncpy(linjs.path, path, sizeof(linjs.path));
+    strncpy(linjs.path, path, sizeof(linjs.path) - 1);
     memcpy(&js->linjs, &linjs, sizeof(linjs));
 
     pollAbsState(js);