From a9eadd9f0117c5d5ce0276768db37eb9282cbe31 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Tue, 20 Feb 2024 18:42:05 +0000 Subject: [PATCH] GCS_MAVLink: FTP: strip trailing `/` in dir list request --- libraries/GCS_MAVLink/GCS_FTP.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS_FTP.cpp b/libraries/GCS_MAVLink/GCS_FTP.cpp index 53ceca24ea..3225688104 100644 --- a/libraries/GCS_MAVLink/GCS_FTP.cpp +++ b/libraries/GCS_MAVLink/GCS_FTP.cpp @@ -624,6 +624,12 @@ void GCS_MAVLINK::ftp_list_dir(struct pending_ftp &request, struct pending_ftp & request.data[sizeof(request.data) - 1] = 0; // ensure the path is null terminated + // Strip trailing / + const size_t dir_len = strlen((char *)request.data); + if ((dir_len > 1) && (request.data[dir_len - 1] == '/')) { + request.data[dir_len - 1] = 0; + } + // open the dir auto *dir = AP::FS().opendir((char *)request.data); if (dir == nullptr) {