aboutsummaryrefslogtreecommitdiff
path: root/src/modules/systemlib/mixer/mixer_multirotor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/systemlib/mixer/mixer_multirotor.cpp')
-rw-r--r--src/modules/systemlib/mixer/mixer_multirotor.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/systemlib/mixer/mixer_multirotor.cpp b/src/modules/systemlib/mixer/mixer_multirotor.cpp
index 576af5e30..2446cc3fb 100644
--- a/src/modules/systemlib/mixer/mixer_multirotor.cpp
+++ b/src/modules/systemlib/mixer/mixer_multirotor.cpp
@@ -183,10 +183,20 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
int used;
const char *end = buf + buflen;
- /* require a space or newline at the end of the buffer */
- if (*end != ' ' && *end != '\n' && *end != '\r') {
- debug("multirotor parser rejected: No newline / space at end of buf.");
- return nullptr;
+ /* enforce that the mixer ends with space or a new line */
+ for (int i = buflen - 1; i >= 0; i--) {
+ if (buf[i] == '\0')
+ continue;
+
+ /* require a space or newline at the end of the buffer, fail on printable chars */
+ if (buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\r') {
+ /* found a line ending or space, so no split symbols / numbers. good. */
+ break;
+ } else {
+ debug("simple parser rejected: No newline / space at end of buf. (#%d/%d: 0x%02x)", i, buflen-1, buf[i]);
+ return nullptr;
+ }
+
}
if (sscanf(buf, "R: %s %d %d %d %d%n", geomname, &s[0], &s[1], &s[2], &s[3], &used) != 5) {