decrypt_push_payload: bugfix

GitOrigin-RevId: 20b8152e77a881937edd1914521408c8aad506fe
This commit is contained in:
Arseny Smirnov 2019-03-25 21:08:48 +13:00
parent fdb870da4d
commit c427880154
2 changed files with 6 additions and 3 deletions

View File

@ -2364,7 +2364,10 @@ Result<string> NotificationManager::decrypt_push_payload(int64 encryption_key_id
if (result.type() != mtproto::Transport::ReadResult::Packet) { if (result.type() != mtproto::Transport::ReadResult::Packet) {
return Status::Error(400, "Wrong packet type"); return Status::Error(400, "Wrong packet type");
} }
return result.packet().str(); if (result.packet().size() < 4) {
return Status::Error(400, "Packet is too small");
}
return result.packet().substr(4).str();
} }
void NotificationManager::before_get_difference() { void NotificationManager::before_get_difference() {

View File

@ -448,8 +448,8 @@ TEST(Mtproto, notifications) {
"H0yJkEMoKRgaF9NaYI4u26oIQ-Ez46kTVU-R7e3acdofOJKm7HIKan_5ZMg82Dvec2M6vc_" "H0yJkEMoKRgaF9NaYI4u26oIQ-Ez46kTVU-R7e3acdofOJKm7HIKan_5ZMg82Dvec2M6vc_"
"I54Vs28iBx8IbBO1y5z9WSScgW3JCvFFKP2MXIu7Jow5-cpUx6jXdzwRUb9RDApwAFKi45zpv8eb3uPCDAmIQ"; "I54Vs28iBx8IbBO1y5z9WSScgW3JCvFFKP2MXIu7Jow5-cpUx6jXdzwRUb9RDApwAFKi45zpv8eb3uPCDAmIQ";
vector<string> decrypted_payloads = { vector<string> decrypted_payloads = {
"fwAAAHsibG9jX2tleSI6Ik1FU1NBR0VfVEVYVCIsImxvY19hcmdzIjpbIkFyc2VueSBTbWlybm92IiwiYWJjZGVmZyJdLCJjdXN0b20iOnsibXNn" "eyJsb2Nfa2V5IjoiTUVTU0FHRV9URVhUIiwibG9jX2FyZ3MiOlsiQXJzZW55IFNtaXJub3YiLCJhYmNkZWZnIl0sImN1c3RvbSI6eyJtc2dfaWQi"
"X2lkIjoiNTkwMDQ3IiwiZnJvbV9pZCI6IjYyODE0In0sImJhZGdlIjoiNDA5In0", "OiI1OTAwNDciLCJmcm9tX2lkIjoiNjI4MTQifSwiYmFkZ2UiOiI0MDkifQ",
"eyJsb2Nfa2V5IjoiIiwibG9jX2FyZ3MiOltdLCJjdXN0b20iOnsiY2hhbm5lbF9pZCI6IjExNzY4OTU0OTciLCJtYXhfaWQiOiIxMzU5In0sImJh" "eyJsb2Nfa2V5IjoiIiwibG9jX2FyZ3MiOltdLCJjdXN0b20iOnsiY2hhbm5lbF9pZCI6IjExNzY4OTU0OTciLCJtYXhfaWQiOiIxMzU5In0sImJh"
"ZGdlIjoiMCJ9"}; "ZGdlIjoiMCJ9"};
key = base64url_decode(key).move_as_ok(); key = base64url_decode(key).move_as_ok();