mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 00:02:34 +01:00
ircd:Ⓜ️ Use canonical path constructions for all generated amalgams.
This commit is contained in:
parent
6a5dbfe228
commit
32732a847b
2 changed files with 18 additions and 32 deletions
|
@ -200,12 +200,14 @@ ircd::m::app::app(const m::event::idx &event_idx)
|
|||
arg.at(0)
|
||||
};
|
||||
|
||||
string_view part[2];
|
||||
part[0] = path;
|
||||
part[1] = file;
|
||||
const string_view part[2]
|
||||
{
|
||||
path, file
|
||||
};
|
||||
|
||||
const auto ret
|
||||
{
|
||||
fs::path_string(part)
|
||||
fs::path_string(path, part)
|
||||
};
|
||||
|
||||
if(!bin.count(ret))
|
||||
|
|
|
@ -878,24 +878,16 @@ command__edit(const mutable_buffer &buf_,
|
|||
"Configure the 'ircd.m.cmd.edit.path' to use this feature.",
|
||||
};
|
||||
|
||||
const string_view parts[2]
|
||||
{
|
||||
edit_path, param["path"]
|
||||
};
|
||||
|
||||
const string_view path
|
||||
{
|
||||
fs::canonical(buf_, edit_path, param["path"])
|
||||
fs::path(buf_, edit_path, parts)
|
||||
};
|
||||
|
||||
const string_view root
|
||||
{
|
||||
fs::canonical(fs::path_scratch, edit_path)
|
||||
};
|
||||
|
||||
if(!startswith(path, root))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"File `%s' was not found under `%s'",
|
||||
path,
|
||||
root,
|
||||
};
|
||||
|
||||
const fs::fd fd
|
||||
{
|
||||
path
|
||||
|
@ -1015,24 +1007,16 @@ try
|
|||
if(!body)
|
||||
return;
|
||||
|
||||
const string_view path_parts[2]
|
||||
{
|
||||
edit_path, args
|
||||
};
|
||||
|
||||
const std::string path
|
||||
{
|
||||
fs::canonical(fs::path_scratch, edit_path, args)
|
||||
fs::path(fs::path_scratch, edit_path, path_parts)
|
||||
};
|
||||
|
||||
const string_view root
|
||||
{
|
||||
fs::canonical(fs::path_scratch, edit_path)
|
||||
};
|
||||
|
||||
if(!startswith(path, root))
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"File `%s' is not under accessible directory `%s'",
|
||||
path,
|
||||
root,
|
||||
};
|
||||
|
||||
fs::write_opts wopts;
|
||||
const const_buffer written
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue