mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
port: reject the CPU port in isolate instead of refusing it silently
parse_isolate() accepted a two digit port and mapped it to logical port 9, the CPU port, while port_isolate() and port_isolation_get() both refuse anything above machine.max_port. Setting the isolation of the CPU port was therefore declined without a word and reading it always answered no members, whatever the hardware held. Bound the port to the front panel, so the command says what it does. The digit is checked before it indexes phys_to_log_port[], which a non numeric argument used to read past.
This commit is contained in:
+5
-5
@@ -428,11 +428,11 @@ void parse_isolate(void)
|
|||||||
|
|
||||||
print_string("\nISOLATE ");
|
print_string("\nISOLATE ");
|
||||||
|
|
||||||
__xdata int8_t port_configured = cmd_buffer[cmd_words_b[1]] - '1';
|
if (!isnumber(cmd_buffer[cmd_words_b[1]]) || cmd_buffer[cmd_words_b[1]] == '0'
|
||||||
port_configured = machine.phys_to_log_port[port_configured];
|
|| isnumber(cmd_buffer[cmd_words_b[1] + 1]))
|
||||||
if (isnumber(cmd_buffer[cmd_words_b[1] + 1])) // CPU-port, logical port 9
|
goto err;
|
||||||
port_configured = (port_configured + 1) * 10 + cmd_buffer[cmd_words_b[1] + 1] - '1';
|
__xdata uint8_t port_configured = machine.phys_to_log_port[cmd_buffer[cmd_words_b[1]] - '1'];
|
||||||
if (port_configured < 0 || port_configured > 9)
|
if (port_configured < machine.min_port || port_configured > machine.max_port)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
print_byte(port_configured); write_char('\n');
|
print_byte(port_configured); write_char('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user