mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
AP_ROMFS: don't list a file as though it were a directory
dir_list() accepted a name matching dirname exactly, so opendir() of a file's path succeeded, and readdir() then skipped past the end of that file's name, taking the name from whatever followed it in memory. Over MAVFTP, listing a path such as @ROMFS/locations.txt was enough. Match only names with a separator after dirname.
This commit is contained in:
committed by
Peter Barker
parent
9a2da82264
commit
c5022fd90c
@@ -121,9 +121,9 @@ const char *AP_ROMFS::dir_list(const char *dirname, uint16_t &ofs)
|
||||
const size_t dlen = strlen(dirname);
|
||||
for ( ; ofs < ARRAY_SIZE(files); ofs++) {
|
||||
if (strncmp(dirname, files[ofs].filename, dlen) == 0) {
|
||||
const char last_char = files[ofs].filename[dlen];
|
||||
if (dlen != 0 && last_char != '/' && last_char != 0) {
|
||||
// only a partial match, skip
|
||||
if (dlen != 0 && files[ofs].filename[dlen] != '/') {
|
||||
// only a partial match, or the name of a file rather than
|
||||
// of a directory holding it, skip
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user