From 9424728af9ca0c78890845052589a9a5751ff084 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 22 Sep 2013 14:19:47 +0200 Subject: Fix a whole bunch of sanity checks across all mixers --- src/modules/systemlib/mixer/mixer.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/modules/systemlib/mixer/mixer.cpp') 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] == ':')) { -- cgit v1.2.3