summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-08-30 15:40:33 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-08-30 15:40:33 +0200
commit57f505c48682385a8943d2d88bbf68632538f339 (patch)
treeb2cbb81cb673a5ce44723cd4e8b6bc8ddf2e428b /src/Cache.cpp
parentDon't trust synapse (diff)
downloadnheko-57f505c48682385a8943d2d88bbf68632538f339.tar.xz
Fix invalid userids on profile requests
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 558eb334..ede2e4e5 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -4464,6 +4464,11 @@ Cache::markUserKeysOutOfDate(lmdb::txn &txn, query.token = sync_token; for (const auto &user : user_ids) { + if (user.size() > 255) { + nhlog::db()->debug("Skipping device key query for user with invalid mxid: {}", user); + continue; + } + nhlog::db()->debug("Marking user keys out of date: {}", user); std::string_view oldKeys; @@ -4504,6 +4509,15 @@ void Cache::query_keys(const std::string &user_id, std::function<void(const UserKeyCache &, mtx::http::RequestErr)> cb) { + if (user_id.size() > 255) { + nhlog::db()->debug("Skipping device key query for user with invalid mxid: {}", user_id); + + mtx::http::ClientError err{}; + err.parse_error = "invalid mxid, more than 255 bytes"; + cb({}, err); + return; + } + mtx::requests::QueryKeys req; std::string last_changed; {