diff --git a/repos/base-linux/src/core/spec/pc/dataspace_component.cc b/repos/base-linux/src/core/spec/pc/dataspace_component.cc index 0fccdef262..7cff814cfc 100644 --- a/repos/base-linux/src/core/spec/pc/dataspace_component.cc +++ b/repos/base-linux/src/core/spec/pc/dataspace_component.cc @@ -34,17 +34,15 @@ using namespace Core; Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) { Session_label const label = label_from_args(args); - Linux_dataspace::Filename fname; - - if (label.last_element().length() > sizeof(fname.buf)) { - Genode::error("file name too long: ", label.last_element()); + if (label.last_element().length() > Linux_dataspace::Filename::capacity()) { + error("file name too long: ", label.last_element()); throw Service_denied(); } - copy_cstring(fname.buf, label.last_element().string(), sizeof(fname.buf)); + Linux_dataspace::Filename const fname = label.last_element(); /* only files inside the current working directory are allowed */ - for (const char *c = fname.buf; *c; ++c) + for (const char *c = fname.string(); *c; ++c) if (*c == '/') throw Service_denied(); return fname; @@ -54,10 +52,10 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) size_t Dataspace_component::_file_size() { Genode::uint64_t size = 0; - if (lx_stat_size(_fname.buf, size) < 0) + if (lx_stat_size(_fname.string(), size) < 0) throw Service_denied(); - return size; + return align_addr((size_t)size, 12); } @@ -66,7 +64,7 @@ Dataspace_component::Dataspace_component(const char *args) _fname(_file_name(args)), _size(_file_size()), _addr(0), - _cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))), + _cap(_fd_to_cap(lx_open(_fname.string(), O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))), _writeable(false), _owner(0) { } @@ -76,6 +74,4 @@ Dataspace_component::Dataspace_component(size_t size, addr_t, addr_t phys_addr, Cache, bool writeable, Dataspace_owner *_owner) : _size(size), _addr(phys_addr), _cap(), _writeable(writeable), _owner(_owner) -{ - _fname.buf[0] = 0; -} +{ }