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) size_t const len = (size_t)(dentry->name_length + 1) > sizeof(e->name)
? sizeof(e->name) : dentry->name_length + 1; ? 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; e->inode = dentry->inode;
break; break;

View File

@@ -589,30 +589,31 @@ class Lwext4_fs::Root : public Root_component<Session_component>
} }
ram_quota -= session_size; ram_quota -= session_size;
char tmp[MAX_PATH_LEN]; Session_policy policy(label, _config_rom.xml());
try {
Session_policy policy(label, _config_rom.xml());
/* determine policy root offset */ /* determine policy root offset */
try { {
policy.attribute("root").value(tmp, sizeof(tmp)); typedef String<MAX_PATH_LEN> Tmp;
session_root.import(tmp, "/mnt"); Tmp const tmp = policy.attribute_value("root", Tmp());
} catch (Xml_node::Nonexistent_attribute) { } if (tmp.valid())
session_root.import(tmp.string(), "/mnt");
/*
* 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);
} }
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 */ /* apply client's root offset */
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/"); {
if (Genode::strcmp("/", tmp, sizeof(tmp))) { char tmp[MAX_PATH_LEN];
session_root.append("/"); Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
session_root.append(tmp); if (Genode::strcmp("/", tmp, sizeof(tmp))) {
session_root.append("/");
session_root.append(tmp);
}
} }
session_root.remove_trailing('/'); session_root.remove_trailing('/');