Browse Source

mixer test: Fix string handling

Some strings were not enforcing NUL termination.
sbg
Lorenz Meier 8 years ago
parent
commit
b9e32d7a34
  1. 6
      src/systemcmds/tests/test_mixer.cpp

6
src/systemcmds/tests/test_mixer.cpp

@ -216,7 +216,9 @@ bool MixerTest::loadAllTest() @@ -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 @@ -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;
}

Loading…
Cancel
Save