diff options
Diffstat (limited to 'netfs/daemon/daemonVolume.cpp')
-rw-r--r-- | netfs/daemon/daemonVolume.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index 9f23b38..0384015 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -11,6 +11,7 @@ #include <entCache.h> #include <fcntl.h> #include <map> +#include <numeric.h> #include <sys/stat.h> #include <unistd.h> @@ -75,7 +76,7 @@ VolumeServer::mknod(const NetFS::ReqEnv re, std::string path, Ice::Int mode, Ice errno = 0; std::filesystem::path p(resolvePath(std::move(path))); mc.AssertWriteParent(p); - if (::mknod(p.c_str(), mode, dev) != 0) { + if (::mknod(p.c_str(), safe {mode}, safe {dev}) != 0) { throw NetFS::SystemError(errno); } } @@ -138,11 +139,11 @@ VolumeServer::readlink(const NetFS::ReqEnv re, std::string path, const Ice::Curr std::string buf(PATH_MAX, 0); std::filesystem::path p(resolvePath(std::move(path))); mc.AssertRead(p); - ssize_t rc = ::readlink(p.c_str(), buf.data(), PATH_MAX); - if (rc == -1) { + auto rc = ::readlink(p.c_str(), buf.data(), PATH_MAX); + if (rc < 0) { throw NetFS::SystemError(errno); } - buf.resize(rc); + buf.resize(safe {rc}); return buf; } @@ -153,7 +154,7 @@ VolumeServer::chmod(const NetFS::ReqEnv re, std::string path, Ice::Int mode, con errno = 0; std::filesystem::path p(resolvePath(std::move(path))); mc.AssertWritePerms(p); - if (::chmod(p.c_str(), mode) != 0) { + if (::chmod(p.c_str(), safe {mode}) != 0) { throw NetFS::SystemError(errno); } } @@ -165,7 +166,7 @@ VolumeServer::chown(const NetFS::ReqEnv re, std::string path, Ice::Int uid, Ice: errno = 0; std::filesystem::path p(resolvePath(std::move(path))); mc.AssertWrite(p); - if (::lchown(p.c_str(), uid, gid) != 0) { + if (::lchown(p.c_str(), safe {uid}, safe {gid}) != 0) { throw NetFS::SystemError(errno); } } @@ -282,7 +283,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv re, std::string path, Ice::Int mode, con errno = 0; std::filesystem::path p(resolvePath(std::move(path))); mc.AssertWriteParent(p); - if (::mkdir(p.c_str(), mode) != 0) { + if (::mkdir(p.c_str(), safe {mode}) != 0) { throw NetFS::SystemError(errno); } if (::chown(p.c_str(), mc.myu, mc.myg) != 0) { |