0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd:Ⓜ️:fed: Fixes for supplied well-known buffer undersizing.

This commit is contained in:
Jason Volk 2020-04-29 01:16:41 -07:00
parent 5fae1f36cf
commit 86a601521d

View file

@ -1845,7 +1845,7 @@ namespace ircd::m::fed
}
ircd::string_view
ircd::m::fed::fetch_well_known(const mutable_buffer &buf,
ircd::m::fed::fetch_well_known(const mutable_buffer &user_buf,
const string_view &origin)
try
{
@ -1854,6 +1854,18 @@ try
"/.well-known/matrix/server"
};
// If the supplied buffer isn't large enough to make the full
// HTTP request, allocate one that is.
const unique_mutable_buffer req_buf
{
size(user_buf) < 8_KiB? 8_KiB: 0UL
};
const mutable_buffer buf
{
req_buf? req_buf: user_buf
};
rfc3986::uri uri;
uri.remote = origin;
uri.path = path;
@ -1918,7 +1930,7 @@ try
// any other incoming content to focus on just the unquoted string.
return string_view
{
data(buf), move(buf, m_server)
data(user_buf), move(user_buf, m_server)
};
}
catch(const ctx::interrupted &)
@ -1954,7 +1966,11 @@ ircd::m::fed::fetch_well_known(const mutable_buffer &buf,
host(remote), "https", port(remote)
};
window_buffer wb{buf};
window_buffer wb
{
buf
};
http::request
{
wb, host(target), "GET", url