lwext4_fs: use copy_cstring, update Xml_node use
Issue genodelabs/genode#3752 Issue genodelabs/genode#3755
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -589,30 +589,31 @@ 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());
|
||||
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) { }
|
||||
|
||||
/*
|
||||
* Determine if the session is writeable.
|
||||
* Policy overrides client argument, both default to false.
|
||||
*/
|
||||
if (policy.attribute_value("writeable", false))
|
||||
writeable = Arg_string::find_arg(args, "writeable").bool_value(false);
|
||||
/* determine policy root offset */
|
||||
{
|
||||
typedef String<MAX_PATH_LEN> Tmp;
|
||||
Tmp const tmp = policy.attribute_value("root", Tmp());
|
||||
if (tmp.valid())
|
||||
session_root.import(tmp.string(), "/mnt");
|
||||
}
|
||||
catch (Session_policy::No_policy_defined) { throw Service_denied(); }
|
||||
|
||||
/*
|
||||
* Determine if the session is writeable.
|
||||
* Policy overrides client argument, both default to false.
|
||||
*/
|
||||
if (policy.attribute_value("writeable", false))
|
||||
writeable = Arg_string::find_arg(args, "writeable").bool_value(false);
|
||||
|
||||
/* apply client's root offset */
|
||||
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
|
||||
if (Genode::strcmp("/", tmp, sizeof(tmp))) {
|
||||
session_root.append("/");
|
||||
session_root.append(tmp);
|
||||
{
|
||||
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('/');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user