From ef88661453ebbff2dbbd6d907f9b2fcc3d7482df Mon Sep 17 00:00:00 2001 From: CLARATION Date: Sat, 1 Aug 2026 02:36:08 -0700 Subject: [PATCH] fix: redo `issue_pongo_command`, add error msg --- src/exploit.c | 2 ++ src/pongo_helper.c | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/exploit.c b/src/exploit.c index f21acba..4be458d 100644 --- a/src/exploit.c +++ b/src/exploit.c @@ -67,6 +67,7 @@ const char* stage_to_string(int stage) case STAGE_YOLODFU: return "Booting PongoOS..."; case STAGE_PONGO: return "Booting..."; case STAGE_DONE: return "Done!"; + case STAGE_ERROR: return "Error!"; default: return "Waiting..."; } } @@ -80,6 +81,7 @@ int stage_to_progress(int stage) case STAGE_YOLODFU: return 60; case STAGE_PONGO: return 70; case STAGE_DONE: return 100; + case STAGE_ERROR: return 99; default: return 0; } } diff --git a/src/pongo_helper.c b/src/pongo_helper.c index e393284..e916cf6 100644 --- a/src/pongo_helper.c +++ b/src/pongo_helper.c @@ -62,9 +62,7 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char if (command != NULL) { size_t len = strlen(command); - // unlikely to happen, unless we add support for pongoterm - // TODO: discuss on adding a pongoterm - if (len > CMD_LENGTH_MAX) { + if (len >= CMD_LENGTH_MAX) { LOG_ERROR("Pongo command too long: %s", command); result.ret = 1; return result; @@ -86,12 +84,8 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char result = send_interface_control_request(handle, 0x21, 3, 0, 0, command_buf, len); if (result.ret != USB_TRANSFER_OK) goto result; #endif - - // return early if the command is boot, we dont care about results - if (strncmp(command,"boot",4) == 0) goto result; } - // TODO: does this work correctly? while (in_progress) { #if WITH_CIDERRAIN result = usb_ctrl_transfer(handle, 0xA1, 2, 0, 0, &in_progress, sizeof(in_progress)); @@ -101,26 +95,26 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char if (result.ret != USB_TRANSFER_OK) goto result; #endif - if (in_progress == 0) break; - - if (outpos + 0x1000 >= sizeof(stdout_buf)) { - memmove(stdout_buf, stdout_buf + 0x1000, sizeof(stdout_buf) - 0x1000); - outpos -= 0x1000; + if (!in_progress) break; + if (outpos > 0x1000) { + memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000); + outpos = 0x1000; } + outlen = 0; #if WITH_CIDERRAIN - result = usb_ctrl_transfer(handle, 0xA1, 1, 0, 0, stdout_buf + outpos, 0x1000); + result = usb_ctrl_transfer(handle, 0xA1, 1, 0, 0, (uint8_t *)(stdout_buf + outpos), 0x1000); if (result.ret != kUSBResponseSuccess) goto result; + outlen = result.wLenDone; #else result = send_interface_control_request(handle, 0xA1, 1, 0, 0, stdout_buf + outpos, 0x1000); if (result.ret != USB_TRANSFER_OK) goto result; + outlen = result.sz; #endif - - outlen = 0x1000; outpos += outlen; } - result: +result: return result; }