From 2c5997cd285896e9e6bcfbea8a8c0f7b972730e9 Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Tue, 24 Jan 2023 02:01:29 +0800 Subject: [PATCH] bootarg check --- README.md | 11 ++++++----- src/main.c | 5 +++++ src/pongo_usb.c | 10 ++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7e99000..7a3f5ef 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,20 @@

- Made with love + Made with love - License + License - Contributors + Contributors - Commits + Commits + goto counter - Discord + Discord

diff --git a/src/main.c b/src/main.c index a8fadb5..27005df 100644 --- a/src/main.c +++ b/src/main.c @@ -136,6 +136,7 @@ void *pongo_usb_callback(void *arg) found_pongo = 1; LOG(LOG_INFO, "Found PongoOS USB Device"); usb_device_handle_t handle = *(usb_device_handle_t *)arg; + issue_pongo_command(handle, NULL); issue_pongo_command(handle, "fuse lock"); issue_pongo_command(handle, "sep auto"); upload_pongo_file(handle, **kpf_to_upload, checkra1n_kpf_pongo_len); @@ -304,6 +305,10 @@ int main(int argc, char *argv[]) kpf_flags |= checkrain_option_verbose_boot; break; case 'e': + if (strstr(optarg, "rootdev=") != NULL) { + LOG(LOG_FATAL, "The boot arg rootdev= is already used by palera1n and cannot be overriden"); + return -1; + } snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg); break; case 'f': diff --git a/src/pongo_usb.c b/src/pongo_usb.c index 0574b4d..11e2941 100644 --- a/src/pongo_usb.c +++ b/src/pongo_usb.c @@ -325,6 +325,10 @@ static void write_stdout(char *buf, uint32_t len) int issue_pongo_command(usb_device_handle_t handle, char *command) { + uint32_t outpos = 0; + uint32_t outlen = 0; + uint8_t in_progress = 1; + if (command == NULL) goto fetch_output; int ret; size_t len = strlen(command); char command_buf[512]; @@ -341,9 +345,7 @@ int issue_pongo_command(usb_device_handle_t handle, char *command) if (ret) goto bad; ret = USBControlTransfer(handle, 0x21, 3, 0, 0, (uint32_t)len, command_buf, NULL); - uint32_t outpos = 0; - uint32_t outlen = 0; - uint8_t in_progress = 1; +fetch_output: while (in_progress) { ret = USBControlTransfer(handle, 0xa1, 2, 0, 0, (uint32_t)sizeof(in_progress), &in_progress, NULL); if (ret == USB_RET_SUCCESS) @@ -370,7 +372,7 @@ bad: { if (ret == USB_RET_NOT_RESPONDING) return 0; - if (!strncmp("boot", command, 4) && ret == USB_RET_IO) + if (command != NULL && (!strncmp("boot", command, 4) && ret == USB_RET_IO)) return 0; LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret)); return ret;