Fix invalid userids on profile requests

This commit is contained in:
Nicolas Werner 2022-08-30 15:40:33 +02:00
parent 47189240a2
commit 57f505c486
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 16 additions and 2 deletions

View File

@ -582,7 +582,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare( FetchContent_Declare(
MatrixClient MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG ce47f0b280c7e5241a556d63c518267d5e6b9c1c GIT_TAG 43e88905659b027bc47c40fe0d31cf28fd639ef9
) )
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")

View File

@ -203,7 +203,7 @@ modules:
buildsystem: cmake-ninja buildsystem: cmake-ninja
name: mtxclient name: mtxclient
sources: sources:
- commit: ce47f0b280c7e5241a556d63c518267d5e6b9c1c - commit: 43e88905659b027bc47c40fe0d31cf28fd639ef9
#tag: v0.8.0 #tag: v0.8.0
type: git type: git
url: https://github.com/Nheko-Reborn/mtxclient.git url: https://github.com/Nheko-Reborn/mtxclient.git

View File

@ -4464,6 +4464,11 @@ Cache::markUserKeysOutOfDate(lmdb::txn &txn,
query.token = sync_token; query.token = sync_token;
for (const auto &user : user_ids) { 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); nhlog::db()->debug("Marking user keys out of date: {}", user);
std::string_view oldKeys; std::string_view oldKeys;
@ -4504,6 +4509,15 @@ void
Cache::query_keys(const std::string &user_id, Cache::query_keys(const std::string &user_id,
std::function<void(const UserKeyCache &, mtx::http::RequestErr)> cb) 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; mtx::requests::QueryKeys req;
std::string last_changed; std::string last_changed;
{ {