lwext4_fs: use copy_cstring, update Xml_node use

Issue genodelabs/genode#3752
Issue genodelabs/genode#3755
This commit is contained in:
Norman Feske
2020-05-20 11:45:25 +02:00
parent 3b7c338c4b
commit 4ef6c7d5ce
2 changed files with 22 additions and 21 deletions

View File

@@ -103,7 +103,7 @@ class Lwext4_fs::Directory : public Node
size_t const len = (size_t)(dentry->name_length + 1) > sizeof(e->name)
? sizeof(e->name) : dentry->name_length + 1;
strncpy(e->name.buf, reinterpret_cast<char const*>(dentry->name), len);
copy_cstring(e->name.buf, reinterpret_cast<char const*>(dentry->name), len);
e->inode = dentry->inode;
break;

View File

@@ -589,15 +589,15 @@ class Lwext4_fs::Root : public Root_component<Session_component>
}
ram_quota -= session_size;
char tmp[MAX_PATH_LEN];
try {
Session_policy policy(label, _config_rom.xml());
/* determine policy root offset */
try {
policy.attribute("root").value(tmp, sizeof(tmp));
session_root.import(tmp, "/mnt");
} catch (Xml_node::Nonexistent_attribute) { }
{
typedef String<MAX_PATH_LEN> Tmp;
Tmp const tmp = policy.attribute_value("root", Tmp());
if (tmp.valid())
session_root.import(tmp.string(), "/mnt");
}
/*
* Determine if the session is writeable.
@@ -605,15 +605,16 @@ class Lwext4_fs::Root : public Root_component<Session_component>
*/
if (policy.attribute_value("writeable", false))
writeable = Arg_string::find_arg(args, "writeable").bool_value(false);
}
catch (Session_policy::No_policy_defined) { throw Service_denied(); }
/* apply client's root offset */
{
char tmp[MAX_PATH_LEN];
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
if (Genode::strcmp("/", tmp, sizeof(tmp))) {
session_root.append("/");
session_root.append(tmp);
}
}
session_root.remove_trailing('/');
char const *root_dir = session_root.base();