mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
ircd:Ⓜ️:fed: Fix cache content buffer overwrite causing erroneous well-known fallback results.
This commit is contained in:
parent
970f84304e
commit
7d949427e3
1 changed files with 8 additions and 17 deletions
|
@ -1722,16 +1722,16 @@ try
|
|||
const_buffer{}
|
||||
};
|
||||
|
||||
const json::string cached
|
||||
{
|
||||
content["m.server"]
|
||||
};
|
||||
|
||||
const seconds ttl
|
||||
{
|
||||
content.get<time_t>("ttl", time_t(86400))
|
||||
};
|
||||
|
||||
const string_view cached
|
||||
{
|
||||
data(buf), move(buf, json::string(content["m.server"]))
|
||||
};
|
||||
|
||||
const system_point expires
|
||||
{
|
||||
origin_server_ts + ttl
|
||||
|
@ -1756,14 +1756,8 @@ try
|
|||
const string_view delegated
|
||||
{
|
||||
expired || !valid?
|
||||
fetch_well_known(buf, origin):
|
||||
|
||||
// Move the returned string to the front of the buffer; this overwrites
|
||||
// other data fetched by the cache query to focus on just the result.
|
||||
string_view
|
||||
{
|
||||
data(buf), move(buf, cached)
|
||||
}
|
||||
fetch_well_known(buf + size(cached), origin):
|
||||
cached
|
||||
};
|
||||
|
||||
// Branch on valid cache hit to return result.
|
||||
|
@ -1804,10 +1798,7 @@ try
|
|||
timef(tmbuf, expires, localtime),
|
||||
};
|
||||
|
||||
return string_view
|
||||
{
|
||||
data(buf), move(buf, cached)
|
||||
};
|
||||
return cached;
|
||||
}
|
||||
|
||||
// Any time the well-known result is the same as the origin (that
|
||||
|
|
Loading…
Reference in a new issue