From 43f844df65f5cf61bdc9a0e5b2b2421a5adf1b17 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 13 Jun 2015 16:20:40 +0100 Subject: Defend against and don't make calls to open with O_CREAT set when re-establishing a session --- netfs/daemon/daemonVolume.cpp | 3 +++ netfs/fuse/fuseApp.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index 0556d9a..afc0d36 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -249,6 +249,9 @@ VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int errno = 0; boost::filesystem::path p(resolvePath(path)); tp.AssertRead(p); + if (flags & O_CREAT) { + throw NetFS::SystemError(EINVAL); + } int fd = ::open(p.string().c_str(), flags); if (fd == -1) { throw NetFS::SystemError(errno); diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index fdcce57..940d0e6 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -117,7 +117,7 @@ NetFS::FuseApp::connectHandles() of.second->remote->ice_ping(); } catch (const Ice::ObjectNotExistException &) { - of.second->remote = volume->open(reqEnv(), of.second->path, of.second->flags); + of.second->remote = volume->open(reqEnv(), of.second->path, of.second->flags & !O_CREAT); } } for (const OpenDirs::value_type & of : openDirs) { -- cgit v1.2.3