console: linenoiseProbe: check if response is valid

Previously linenoiseProbe would accept any 4 byte response, even one
that isn't expected. This adds a check that the first byte of the
response is ESC.
Suggested in https://github.com/espressif/esp-idf/issues/8839.
This commit is contained in:
Ivan Grokhotkov
2022-05-03 21:26:14 +02:00
parent 78480e215a
commit 129cdcc08c

View File

@@ -1057,6 +1057,10 @@ int linenoiseProbe(void) {
if (cb < 0) { if (cb < 0) {
continue; continue;
} }
if (read_bytes == 0 && c != '\x1b') {
/* invalid response */
break;
}
read_bytes += cb; read_bytes += cb;
} }
/* Restore old mode */ /* Restore old mode */