mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sim] Fix stringop truncation warning from GCC 10 (#2945)
If the strncpy() bound is equal to the destination size and the source string is longer than 256 bytes, strncpy() won't write a null terminator for the destination string.
This commit is contained in:
@@ -557,7 +557,8 @@ void GlfwSystemJoystick::GetData(HALJoystickData* data, bool mapGamepad) const {
|
||||
// copy into HAL structures
|
||||
data->desc.isXbox = m_isGamepad ? 1 : 0;
|
||||
data->desc.type = m_isGamepad ? 21 : 20;
|
||||
std::strncpy(data->desc.name, m_name, 256);
|
||||
std::strncpy(data->desc.name, m_name, sizeof(data->desc.name) - 1);
|
||||
data->desc.name[sizeof(data->desc.name) - 1] = '\0';
|
||||
data->desc.axisCount = (std::min)(m_axisCount, HAL_kMaxJoystickAxes);
|
||||
// desc.axisTypes ???
|
||||
data->desc.buttonCount = (std::min)(m_buttonCount, 32);
|
||||
|
||||
Reference in New Issue
Block a user