From 01a26a90114d7c869a58919160673498d5761a74 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 13 Apr 2021 07:28:10 +0900 Subject: [PATCH] Do not allow open with O_RDONLY and O_TRUNC (#1620) Found via pjdfstests. References #1589. --- src/s3fs.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index cd02e6c..0ad6be6 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -2204,6 +2204,10 @@ static int s3fs_open(const char* _path, struct fuse_file_info* fi) S3FS_PRN_INFO("[path=%s][flags=0x%x]", path, fi->flags); + if ((fi->flags & O_ACCMODE) == O_RDONLY && fi->flags & O_TRUNC) { + return -EACCES; + } + // clear stat for reading fresh stat. // (if object stat is changed, we refresh it. then s3fs gets always // stat when s3fs open the object).