Skip to content

Commit c427880

Browse files
committed
decrypt_push_payload: bugfix
GitOrigin-RevId: 20b8152e77a881937edd1914521408c8aad506fe
1 parent fdb870d commit c427880

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

td/telegram/NotificationManager.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,10 @@ Result<string> NotificationManager::decrypt_push_payload(int64 encryption_key_id
23642364
if (result.type() != mtproto::Transport::ReadResult::Packet) {
23652365
return Status::Error(400, "Wrong packet type");
23662366
}
2367-
return result.packet().str();
2367+
if (result.packet().size() < 4) {
2368+
return Status::Error(400, "Packet is too small");
2369+
}
2370+
return result.packet().substr(4).str();
23682371
}
23692372

23702373
void NotificationManager::before_get_difference() {

test/mtproto.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ TEST(Mtproto, notifications) {
448448
"H0yJkEMoKRgaF9NaYI4u26oIQ-Ez46kTVU-R7e3acdofOJKm7HIKan_5ZMg82Dvec2M6vc_"
449449
"I54Vs28iBx8IbBO1y5z9WSScgW3JCvFFKP2MXIu7Jow5-cpUx6jXdzwRUb9RDApwAFKi45zpv8eb3uPCDAmIQ";
450450
vector<string> decrypted_payloads = {
451-
"fwAAAHsibG9jX2tleSI6Ik1FU1NBR0VfVEVYVCIsImxvY19hcmdzIjpbIkFyc2VueSBTbWlybm92IiwiYWJjZGVmZyJdLCJjdXN0b20iOnsibXNn"
452-
"X2lkIjoiNTkwMDQ3IiwiZnJvbV9pZCI6IjYyODE0In0sImJhZGdlIjoiNDA5In0",
451+
"eyJsb2Nfa2V5IjoiTUVTU0FHRV9URVhUIiwibG9jX2FyZ3MiOlsiQXJzZW55IFNtaXJub3YiLCJhYmNkZWZnIl0sImN1c3RvbSI6eyJtc2dfaWQi"
452+
"OiI1OTAwNDciLCJmcm9tX2lkIjoiNjI4MTQifSwiYmFkZ2UiOiI0MDkifQ",
453453
"eyJsb2Nfa2V5IjoiIiwibG9jX2FyZ3MiOltdLCJjdXN0b20iOnsiY2hhbm5lbF9pZCI6IjExNzY4OTU0OTciLCJtYXhfaWQiOiIxMzU5In0sImJh"
454454
"ZGdlIjoiMCJ9"};
455455
key = base64url_decode(key).move_as_ok();

0 commit comments

Comments
 (0)