Add error on too long proxy secret.

GitOrigin-RevId: 14321993a0793cf454a0e12de4109dbd0c180b67
This commit is contained in:
levlam 2020-01-24 18:33:17 +03:00
parent 3a78a9160b
commit 21f1f4510c

View File

@ -24,6 +24,9 @@ Result<ProxySecret> ProxySecret::from_link(Slice encoded_secret) {
}
Result<ProxySecret> ProxySecret::from_binary(Slice raw_unchecked_secret) {
if (raw_unchecked_secret.size() > 17 + 255) {
return Status::Error(400, "Too long secret");
}
if (raw_unchecked_secret.size() == 16 ||
(raw_unchecked_secret.size() == 17 && static_cast<unsigned char>(raw_unchecked_secret[0]) == 0xdd) ||
(raw_unchecked_secret.size() >= 18 && static_cast<unsigned char>(raw_unchecked_secret[0]) == 0xee)) {