aboutsummaryrefslogtreecommitdiff
path: root/src/modules/systemlib/mixer/mixer.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-09-22 14:19:47 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-09-22 14:20:19 +0200
commit9424728af9ca0c78890845052589a9a5751ff084 (patch)
treeeb1c862a1fc29772be5af49c357089faa06cd4f8 /src/modules/systemlib/mixer/mixer.cpp
parentd29a1b69e540975f22c6b517bc46a256258b77f0 (diff)
downloadpx4-firmware-9424728af9ca0c78890845052589a9a5751ff084.tar.gz
px4-firmware-9424728af9ca0c78890845052589a9a5751ff084.tar.bz2
px4-firmware-9424728af9ca0c78890845052589a9a5751ff084.zip
Fix a whole bunch of sanity checks across all mixers
Diffstat (limited to 'src/modules/systemlib/mixer/mixer.cpp')
-rw-r--r--src/modules/systemlib/mixer/mixer.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/modules/systemlib/mixer/mixer.cpp b/src/modules/systemlib/mixer/mixer.cpp
index 7d9ddba8f..b1bb1a66d 100644
--- a/src/modules/systemlib/mixer/mixer.cpp
+++ b/src/modules/systemlib/mixer/mixer.cpp
@@ -144,9 +144,19 @@ NullMixer::from_text(const char *buf, unsigned &buflen)
NullMixer *nm = nullptr;
const char *end = buf + buflen;
- /* require a space or newline at the end of the buffer */
- if (*end != ' ' && *end != '\n' && *end != '\r') {
- return nm;
+ /* 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 {
+ return nm;
+ }
+
}
if ((buflen >= 2) && (buf[0] == 'Z') && (buf[1] == ':')) {