summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-10-11 12:38:28 +0200
committerGravatar Nikias Bassen2022-10-11 12:38:28 +0200
commitd526c74e0562f7991bde3ec7d156cbf8b0b10bd5 (patch)
tree70a793311e482b0293fb4f0d014c2636e36af614
parent0fe2ca4077fef9fda050ace39b549f63d3043462 (diff)
downloadlibirecovery-d526c74e0562f7991bde3ec7d156cbf8b0b10bd5.tar.gz
libirecovery-d526c74e0562f7991bde3ec7d156cbf8b0b10bd5.tar.bz2
irecovery: Make sure to send certain commands with bRequest set to 1
-rw-r--r--tools/irecovery.c22
1 files 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() {
199 } 199 }
200} 200}
201 201
202static int _is_breq_command(const char* cmd)
203{
204 return (
205 !strcmp(cmd, "go")
206 || !strcmp(cmd, "bootx")
207 || !strcmp(cmd, "reboot")
208 || !strcmp(cmd, "memboot")
209 );
210}
211
202static void parse_command(irecv_client_t client, unsigned char* command, unsigned int size) { 212static void parse_command(irecv_client_t client, unsigned char* command, unsigned int size) {
203 char* cmd = strdup((char*)command); 213 char* cmd = strdup((char*)command);
204 char* action = strtok(cmd, " "); 214 char* action = strtok(cmd, " ");
@@ -269,7 +279,11 @@ static void init_shell(irecv_client_t client) {
269 279
270 char* cmd = readline("> "); 280 char* cmd = readline("> ");
271 if (cmd && *cmd) { 281 if (cmd && *cmd) {
272 error = irecv_send_command(client, cmd); 282 if (_is_breq_command(cmd)) {
283 error = irecv_send_command_breq(client, cmd, 1);
284 } else {
285 error = irecv_send_command(client, cmd);
286 }
273 if (error != IRECV_E_SUCCESS) { 287 if (error != IRECV_E_SUCCESS) {
274 quit = 1; 288 quit = 1;
275 } 289 }
@@ -560,7 +574,11 @@ int main(int argc, char* argv[]) {
560 break; 574 break;
561 575
562 case kSendCommand: 576 case kSendCommand:
563 error = irecv_send_command(client, argument); 577 if (_is_breq_command(argument)) {
578 error = irecv_send_command_breq(client, argument, 1);
579 } else {
580 error = irecv_send_command(client, argument);
581 }
564 debug("%s\n", irecv_strerror(error)); 582 debug("%s\n", irecv_strerror(error));
565 break; 583 break;
566 584