Skip to content

Commit

Permalink
GCS_MAVLink: FTP: strip trailing / in dir list request
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 authored and tridge committed Feb 21, 2024
1 parent 785e0c4 commit a9eadd9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/GCS_MAVLink/GCS_FTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a9eadd9

Please sign in to comment.