mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 11:07:34 +08:00
mixer test: Fix string handling
Some strings were not enforcing NUL termination.
This commit is contained in:
@@ -216,7 +216,9 @@ bool MixerTest::loadAllTest()
|
||||
if (strncmp(result->d_name, ".", 1) != 0) {
|
||||
|
||||
char buf[PATH_MAX];
|
||||
(void)strncpy(&buf[0], MIXER_ONBOARD_PATH, sizeof(buf));
|
||||
(void)strncpy(&buf[0], MIXER_ONBOARD_PATH, sizeof(buf) - 1);
|
||||
/* enforce null termination */
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
(void)strncpy(&buf[strlen(MIXER_ONBOARD_PATH)], "/", 1);
|
||||
(void)strncpy(&buf[strlen(MIXER_ONBOARD_PATH) + 1], result->d_name, sizeof(buf) - strlen(MIXER_ONBOARD_PATH) - 1);
|
||||
|
||||
@@ -597,7 +599,7 @@ mixer_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index, f
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (control_index > (sizeof(actuator_controls) / sizeof(actuator_controls[0]))) {
|
||||
if (control_index >= (sizeof(actuator_controls) / sizeof(actuator_controls[0]))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user