1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 21:21:24 +01:00

improve parameter check for 'a' command

This commit is contained in:
Harald Barth 2022-07-06 21:12:10 +02:00
parent 632e9335f3
commit 76d6759d98

View File

@ -308,6 +308,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
address=p[0]; address=p[0];
subaddress=p[1]; subaddress=p[1];
activep=2; activep=2;
if ((p[3] < 0) || (p[3] > 1)) // invalid onoff 0|1
break;
onoff=p[3]; onoff=p[3];
} }
else break; // invalid no of parameters else break; // invalid no of parameters
@ -315,8 +317,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
if ( if (
((address & 0x01FF) != address) // invalid address (limit 9 bits) ((address & 0x01FF) != address) // invalid address (limit 9 bits)
|| ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits) || ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits)
|| ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1 || (p[activep] > 1) || (p[activep] < 0) // invalid activate 0|1
|| (onoff > 2) // invalid onoff 0|1|2
) break; ) break;
// Honour the configuration option (config.h) which allows the <a> command to be reversed // Honour the configuration option (config.h) which allows the <a> command to be reversed
#ifdef DCC_ACCESSORY_COMMAND_REVERSE #ifdef DCC_ACCESSORY_COMMAND_REVERSE