1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-04-21 04:21:20 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Harald Barth
f868604ca9 version 5.4.4 2025-01-31 11:22:55 +01:00
Harald Barth
41168a9dd8 Bugfix: trailing > in command was not replaced with \0 which did break <+> commands 2025-01-31 11:19:22 +01:00
Harald Barth
0154e7fd78 Bugfix: serial COMMAND_BUFFER_SIZE could be silently overrun 2025-01-31 11:17:59 +01:00
3 changed files with 35 additions and 27 deletions

View File

@ -167,8 +167,10 @@ int16_t DCCEXParser::splitValues(int16_t result[MAX_COMMAND_PARAMS], byte *cmd,
break; break;
if (hot == '\0') if (hot == '\0')
return -1; return -1;
if (hot == '>') if (hot == '>') {
*remainingCmd = '\0'; // terminate the cmd string with 0 instead of '>'
return parameterCount; return parameterCount;
}
state = 2; state = 2;
continue; continue;
@ -265,8 +267,9 @@ void DCCEXParser::parse(const FSH * cmd) {
// See documentation on DCC class for info on this section // See documentation on DCC class for info on this section
void DCCEXParser::parse(Print *stream, byte *com, RingStream *ringStream) { void DCCEXParser::parse(Print *stream, byte *com, RingStream *ringStream) {
// This function can get stings of the form "<C OMM AND>" or "C OMM AND" // This function can get stings of the form "<C OMM AND>" or "C OMM AND>"
// found is true first after the leading "<" has been passed // found is true first after the leading "<" has been passed which results
// in parseOne() getting c="C OMM AND>"
bool found = (com[0] != '<'); bool found = (com[0] != '<');
for (byte *c=com; c[0] != '\0'; c++) { for (byte *c=com; c[0] != '\0'; c++) {
if (found) { if (found) {

View File

@ -126,8 +126,8 @@ void SerialManager::loop2() {
buffer[0] = '\0'; buffer[0] = '\0';
} }
} else { // if (inCommandPayload) } else { // if (inCommandPayload)
if (bufferLength < (COMMAND_BUFFER_SIZE-1)) if (bufferLength < (COMMAND_BUFFER_SIZE-1)) {
buffer[bufferLength++] = ch; buffer[bufferLength++] = ch; // advance bufferLength
if (inCommandPayload > PAYLOAD_NORMAL) { if (inCommandPayload > PAYLOAD_NORMAL) {
if (inCommandPayload > 32 + 2) { // String way too long if (inCommandPayload > 32 + 2) { // String way too long
ch = '>'; // we end this nonsense ch = '>'; // we end this nonsense
@ -142,14 +142,18 @@ void SerialManager::loop2() {
} }
if (inCommandPayload == PAYLOAD_NORMAL) { if (inCommandPayload == PAYLOAD_NORMAL) {
if (ch == '>') { if (ch == '>') {
buffer[bufferLength] = '\0'; buffer[bufferLength] = '\0'; // This \0 is after the '>'
DCCEXParser::parse(serial, buffer, NULL); DCCEXParser::parse(serial, buffer, NULL); // buffer parsed with trailing '>'
inCommandPayload = PAYLOAD_FALSE; inCommandPayload = PAYLOAD_FALSE;
break; break;
} else if (ch == '"') { } else if (ch == '"') {
inCommandPayload = PAYLOAD_STRING; inCommandPayload = PAYLOAD_STRING;
} }
} }
} else {
DIAG(F("Parse error: input buffer overflow"));
inCommandPayload = PAYLOAD_FALSE;
}
} }
} }
} }

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.4.3" #define VERSION "5.4.4"
// 5.4.4 - bugfix in parser, input buffer overrun and trailing > that did break <+>
// 5.4.3 - bugfix changeFn for functions 29..31 // 5.4.3 - bugfix changeFn for functions 29..31
// 5.4.2 - Reversed turnout bugfix // 5.4.2 - Reversed turnout bugfix
// 5.4.1 - ESP32 bugfix packet buffer race // 5.4.1 - ESP32 bugfix packet buffer race