mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-21 23:33:57 -04:00
AP_Filesystem: fixed fseek and open of directories
This commit is contained in:
parent
a77331e725
commit
0f0aed66b7
@ -58,6 +58,12 @@ int AP_Filesystem_Posix::open(const char *fname, int flags, bool allow_absolute_
|
||||
if (! allow_absolute_paths) {
|
||||
fname = map_filename(fname);
|
||||
}
|
||||
struct stat st;
|
||||
if (::stat(fname, &st) == 0 &&
|
||||
((st.st_mode & S_IFMT) != S_IFREG && (st.st_mode & S_IFMT) != S_IFLNK)) {
|
||||
// only allow links and files
|
||||
return -1;
|
||||
}
|
||||
// we automatically add O_CLOEXEC as we always want it for ArduPilot FS usage
|
||||
return ::open(fname, flags | O_CLOEXEC, 0644);
|
||||
}
|
||||
|
@ -170,7 +170,8 @@ int apfs_fseek(APFS_FILE *stream, long offset, int whence)
|
||||
{
|
||||
CHECK_STREAM(stream, EOF);
|
||||
stream->eof = false;
|
||||
return AP::FS().lseek(stream->fd, offset, whence);
|
||||
AP::FS().lseek(stream->fd, offset, whence);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int apfs_ferror(APFS_FILE *stream)
|
||||
|
Loading…
Reference in New Issue
Block a user