mixer test: Fix string handling

Some strings were not enforcing NUL termination.
This commit is contained in:
Lorenz Meier 2017-01-14 14:12:18 +01:00
parent 1155a4725b
commit b9e32d7a34

View File

@ -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;
}