diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index c90fc6121d..c448a4ebb3 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -196,11 +196,11 @@ bool MixerTest::loadAllTest() if (strncmp(result->d_name, ".", 1) != 0) { char buf[PATH_MAX]; - (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); + + if (snprintf(buf, PATH_MAX, "%s/%s", MIXER_ONBOARD_PATH, result->d_name) >= PATH_MAX) { + PX4_ERR("mixer path too long %s", result->d_name); + return false; + } bool ret = load_mixer(buf, 0);