From d526c74e0562f7991bde3ec7d156cbf8b0b10bd5 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 11 Oct 2022 12:38:28 +0200 Subject: irecovery: Make sure to send certain commands with bRequest set to 1 --- tools/irecovery.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/irecovery.c b/tools/irecovery.c index 392f912..faf0a92 100644 --- a/tools/irecovery.c +++ b/tools/irecovery.c @@ -199,6 +199,16 @@ static void print_devices() { } } +static int _is_breq_command(const char* cmd) +{ + return ( + !strcmp(cmd, "go") + || !strcmp(cmd, "bootx") + || !strcmp(cmd, "reboot") + || !strcmp(cmd, "memboot") + ); +} + static void parse_command(irecv_client_t client, unsigned char* command, unsigned int size) { char* cmd = strdup((char*)command); char* action = strtok(cmd, " "); @@ -269,7 +279,11 @@ static void init_shell(irecv_client_t client) { char* cmd = readline("> "); if (cmd && *cmd) { - error = irecv_send_command(client, cmd); + if (_is_breq_command(cmd)) { + error = irecv_send_command_breq(client, cmd, 1); + } else { + error = irecv_send_command(client, cmd); + } if (error != IRECV_E_SUCCESS) { quit = 1; } @@ -560,7 +574,11 @@ int main(int argc, char* argv[]) { break; case kSendCommand: - error = irecv_send_command(client, argument); + if (_is_breq_command(argument)) { + error = irecv_send_command_breq(client, argument, 1); + } else { + error = irecv_send_command(client, argument); + } debug("%s\n", irecv_strerror(error)); break; -- cgit v1.1-32-gdbae