From 9d574b2de0a3ba9cd2ef27359d745343c02420fc Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 7 Jun 2025 16:03:04 +1200 Subject: [PATCH] ensure user isn't removing invalid path --- examples/companion_radio/MyMesh.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 63fbf142..4d3860c3 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -1357,13 +1357,20 @@ void MyMesh::checkCLIRescueCmd() { // get path from command e.g: "rm /adv_blobs" const char *path = &cli_command[4]; - - // remove file - bool removed = _store->removeFile(path); - if(removed){ - Serial.println("File removed"); + + // ensure path is not empty, or root dir + if(!path || strlen(path) == 0 || strcmp(path, "/") == 0){ + Serial.println("Invalid path provided"); } else { - Serial.println("Failed to remove file"); + + // remove file + bool removed = _store->removeFile(path); + if(removed){ + Serial.println("File removed"); + } else { + Serial.println("Failed to remove file"); + } + } } else if (strcmp(cli_command, "reboot") == 0) {