diff options
author | George Hazan <ghazan@miranda.im> | 2022-11-16 18:02:03 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-11-16 18:02:03 +0300 |
commit | 3dcba5c9f24d127b538051bc0b9fcf3d59cb84aa (patch) | |
tree | 4e313fae53f6de3ad9c2e12b0f60723b39712966 | |
parent | 56d8aec9fd39699ea71f492741c785487e862630 (diff) |
WhatsApp: sender key name normalization
-rw-r--r-- | protocols/WhatsApp/src/signal.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/protocols/WhatsApp/src/signal.cpp b/protocols/WhatsApp/src/signal.cpp index e9ec23b014..16d6c47df5 100644 --- a/protocols/WhatsApp/src/signal.cpp +++ b/protocols/WhatsApp/src/signal.cpp @@ -338,11 +338,17 @@ static int is_trusted_identity(const signal_protocol_address * /*address*/, uint return 1; } +static CMStringA get_sender_setting(const signal_protocol_sender_key_name *skn) +{ + WAJid jid(CMStringA(skn->sender.name, (int)skn->sender.name_len)); + return CMStringA(FORMAT, "SenderKey_%*s_%s_%d", (unsigned)skn->group_id_len, skn->group_id, jid.user.c_str(), skn->sender.device_id); +} + static int load_sender_key(signal_buffer **record, signal_buffer **, const signal_protocol_sender_key_name *skn, void *user_data) { auto *pStore = (MSignalStore *)user_data; - CMStringA szSetting(FORMAT, "SenderKey_%*s_%*s_%d", (unsigned)skn->group_id_len, skn->group_id, (unsigned)skn->sender.name_len, skn->sender.name, skn->sender.device_id); + CMStringA szSetting(get_sender_setting(skn)); MBinBuffer blob(pStore->pProto->getBlob(szSetting)); if (blob.isEmpty()) return 0; @@ -355,7 +361,7 @@ static int store_sender_key(const signal_protocol_sender_key_name *skn, uint8_t { auto *pStore = (MSignalStore *)user_data; - CMStringA szSetting(FORMAT, "SenderKey_%*s_%*s_%d", (unsigned)skn->group_id_len, skn->group_id, (unsigned)skn->sender.name_len, skn->sender.name, skn->sender.device_id); + CMStringA szSetting(get_sender_setting(skn)); db_set_blob(0, pStore->pProto->m_szModuleName, szSetting, record, (unsigned)record_len); return 0; } |