diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index ea76808300..2ce8e3cd4a 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -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; }