Skip to content

Commit 9d574b2

Browse files
committed
ensure user isn't removing invalid path
1 parent a22c176 commit 9d574b2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,13 +1357,20 @@ void MyMesh::checkCLIRescueCmd() {
13571357

13581358
// get path from command e.g: "rm /adv_blobs"
13591359
const char *path = &cli_command[4];
1360-
1361-
// remove file
1362-
bool removed = _store->removeFile(path);
1363-
if(removed){
1364-
Serial.println("File removed");
1360+
1361+
// ensure path is not empty, or root dir
1362+
if(!path || strlen(path) == 0 || strcmp(path, "/") == 0){
1363+
Serial.println("Invalid path provided");
13651364
} else {
1366-
Serial.println("Failed to remove file");
1365+
1366+
// remove file
1367+
bool removed = _store->removeFile(path);
1368+
if(removed){
1369+
Serial.println("File removed");
1370+
} else {
1371+
Serial.println("Failed to remove file");
1372+
}
1373+
13671374
}
13681375

13691376
} else if (strcmp(cli_command, "reboot") == 0) {

0 commit comments

Comments
 (0)