summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-01-12 23:36:39 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-01-12 23:36:39 +0000
commited2547d61c8453df8bfad9bec40c0b5f53d1f04c (patch)
tree4f1ed0709c09874a5cdf34dc239f49dac2807334
parentAdd missing check that path params don't attempt to navigate outside of the s... (diff)
downloadnetfs-ed2547d61c8453df8bfad9bec40c0b5f53d1f04c.tar.bz2
netfs-ed2547d61c8453df8bfad9bec40c0b5f53d1f04c.tar.xz
netfs-ed2547d61c8453df8bfad9bec40c0b5f53d1f04c.zip
Use path's own c_str, no need to string it first
-rw-r--r--netfs/daemon/daemonVolume.cpp50
-rw-r--r--netfs/daemon/modeCheck.cpp2
2 files changed, 26 insertions, 26 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp
index 7ab8bd1..9aab62c 100644
--- a/netfs/daemon/daemonVolume.cpp
+++ b/netfs/daemon/daemonVolume.cpp
@@ -41,7 +41,7 @@ VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::In
ModeCheck mc(re, root, userLookup, groupLookup);
struct stat s;
boost::filesystem::path p(resolvePath(path));
- if (::stat(p.string().c_str(), &s) != 0) {
+ if (::stat(p.c_str(), &s) != 0) {
return errno;
}
if (mode == F_OK) {
@@ -68,7 +68,7 @@ VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const
struct stat s;
boost::filesystem::path p(resolvePath(path));
mc.AssertRead(p.parent_path());
- if (::lstat(p.string().c_str(), &s) != 0) {
+ if (::lstat(p.c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
NetFS::Attr a;
@@ -83,7 +83,7 @@ VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p.parent_path());
- if (::mknod(p.string().c_str(), mode, dev) != 0) {
+ if (::mknod(p.c_str(), mode, dev) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -95,11 +95,11 @@ VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const
errno = 0;
boost::filesystem::path p(resolvePath(path2));
mc.AssertWrite(p.parent_path());
- if (::symlink(path1.c_str(), p.string().c_str()) != 0) {
+ if (::symlink(path1.c_str(), p.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
- if (::lchown(p.string().c_str(), mc.myu, mc.myg) != 0) {
- ::unlink(p.string().c_str());
+ if (::lchown(p.c_str(), mc.myu, mc.myg) != 0) {
+ ::unlink(p.c_str());
throw NetFS::SystemError(errno);
}
}
@@ -111,11 +111,11 @@ VolumeServer::link(const NetFS::ReqEnv & re, const std::string & path1, const st
errno = 0;
boost::filesystem::path p1(resolvePath(path1));
boost::filesystem::path p2(resolvePath(path2));
- if (::link(p1.string().c_str(), p2.string().c_str()) != 0) {
+ if (::link(p1.c_str(), p2.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
- if (::chown(p2.string().c_str(), mc.myu, mc.myg) != 0) {
- ::unlink(p2.string().c_str());
+ if (::chown(p2.c_str(), mc.myu, mc.myg) != 0) {
+ ::unlink(p2.c_str());
throw NetFS::SystemError(errno);
}
}
@@ -135,7 +135,7 @@ VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const s
else {
mc.AssertWrite(t.parent_path());
}
- if (::rename(f.string().c_str(), t.string().c_str()) != 0) {
+ if (::rename(f.c_str(), t.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -148,7 +148,7 @@ VolumeServer::readlink(const NetFS::ReqEnv & re, const std::string & path, const
char buf[PATH_MAX];
boost::filesystem::path p(resolvePath(path));
mc.AssertRead(p);
- ssize_t rc = ::readlink(p.string().c_str(), buf, PATH_MAX);
+ ssize_t rc = ::readlink(p.c_str(), buf, PATH_MAX);
if (rc == -1) {
throw NetFS::SystemError(errno);
}
@@ -162,7 +162,7 @@ VolumeServer::chmod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
- if (::chmod(p.string().c_str(), mode) != 0) {
+ if (::chmod(p.c_str(), mode) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -174,7 +174,7 @@ VolumeServer::chown(const NetFS::ReqEnv & re, const std::string & path, Ice::Int
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
- if (::lchown(p.string().c_str(), uid, gid) != 0) {
+ if (::lchown(p.c_str(), uid, gid) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -192,7 +192,7 @@ VolumeServer::utimens(const NetFS::ReqEnv & re, const std::string & path,
times[1].tv_nsec = ns1;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
- if (::utimensat(0, p.string().c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
+ if (::utimensat(0, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -205,7 +205,7 @@ VolumeServer::statfs(const NetFS::ReqEnv & re, const std::string & path, const I
struct statvfs s;
boost::filesystem::path p(resolvePath(path));
mc.AssertRead(p);
- if (::statvfs(p.string().c_str(), &s) != 0) {
+ if (::statvfs(p.c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
NetFS::VFS t;
@@ -220,7 +220,7 @@ VolumeServer::truncate(const NetFS::ReqEnv & re, const std::string & path, Ice::
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
- if (::truncate(p.string().c_str(), size) != 0) {
+ if (::truncate(p.c_str(), size) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -233,7 +233,7 @@ VolumeServer::unlink(const NetFS::ReqEnv & re, const std::string & path, const I
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
mc.AssertWrite(p.parent_path());
- if (::unlink(p.string().c_str()) != 0) {
+ if (::unlink(p.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
}
@@ -254,7 +254,7 @@ VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int
if (flags & O_CREAT) {
throw NetFS::SystemError(EINVAL);
}
- int fd = ::open(p.string().c_str(), flags);
+ int fd = ::open(p.c_str(), flags);
if (fd == -1) {
throw NetFS::SystemError(errno);
}
@@ -268,13 +268,13 @@ VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::In
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p.parent_path());
- int fd = ::open(p.string().c_str(), O_CREAT | flags, mode);
+ int fd = ::open(p.c_str(), O_CREAT | flags, mode);
if (fd == -1) {
throw NetFS::SystemError(errno);
}
if (fchown(fd, mc.myu, mc.myg) != 0) {
::close(fd);
- ::unlink(p.string().c_str());
+ ::unlink(p.c_str());
throw NetFS::SystemError(errno);
}
return NetFS::FilePrx::checkedCast(ice.adapter->addWithUUID(new FileServer(fd, userLookup, groupLookup)));
@@ -287,7 +287,7 @@ VolumeServer::opendir(const NetFS::ReqEnv & re, const std::string & path, const
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertRead(p);
- DIR * od = ::opendir(p.string().c_str());
+ DIR * od = ::opendir(p.c_str());
if (!od) {
throw NetFS::SystemError(errno);
}
@@ -301,11 +301,11 @@ VolumeServer::mkdir(const NetFS::ReqEnv & re, const std::string & path, Ice::Int
errno = 0;
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p.parent_path());
- if (::mkdir(p.string().c_str(), mode) != 0) {
+ if (::mkdir(p.c_str(), mode) != 0) {
throw NetFS::SystemError(errno);
}
- if (::chown(p.string().c_str(), mc.myu, mc.myg) != 0) {
- ::rmdir(p.string().c_str());
+ if (::chown(p.c_str(), mc.myu, mc.myg) != 0) {
+ ::rmdir(p.c_str());
throw NetFS::SystemError(errno);
}
}
@@ -318,7 +318,7 @@ VolumeServer::rmdir(const NetFS::ReqEnv & re, const std::string & path, const Ic
boost::filesystem::path p(resolvePath(path));
mc.AssertWrite(p);
mc.AssertWrite(p.parent_path());
- if (::rmdir(p.string().c_str()) != 0) {
+ if (::rmdir(p.c_str()) != 0) {
throw NetFS::SystemError(errno);
}
}
diff --git a/netfs/daemon/modeCheck.cpp b/netfs/daemon/modeCheck.cpp
index 36fe92d..8468f52 100644
--- a/netfs/daemon/modeCheck.cpp
+++ b/netfs/daemon/modeCheck.cpp
@@ -37,7 +37,7 @@ struct stat
ModeCheck::lstat(const boost::filesystem::path & p)
{
struct stat s;
- if (::lstat(p.string().c_str(), &s) != 0) {
+ if (::lstat(p.c_str(), &s) != 0) {
throw NetFS::SystemError(errno);
}
return s;