From dd05ff5156d926b4673ffd2d84cca233f651b5c1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 1 Jan 2017 18:34:53 +0100 Subject: [PATCH] Multirotor mixer: Remove incorrect pre-parser and replace with fixed central implementation --- .../systemlib/mixer/mixer_multirotor.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/modules/systemlib/mixer/mixer_multirotor.cpp b/src/modules/systemlib/mixer/mixer_multirotor.cpp index 5eebb935e9..2aa6735fe4 100644 --- a/src/modules/systemlib/mixer/mixer_multirotor.cpp +++ b/src/modules/systemlib/mixer/mixer_multirotor.cpp @@ -116,22 +116,9 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl int s[4]; int used; - /* 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; - } - + /* enforce that the mixer ends with a new line */ + if (!string_well_formed(buf, buflen)) { + return nullptr; } if (sscanf(buf, "R: %7s %d %d %d %d%n", geomname, &s[0], &s[1], &s[2], &s[3], &used) != 5) {