Fix #16327: Crash supplying a bad signature size in the auth packet

This commit is contained in:
ζeh Matt 2021-12-28 16:36:13 +02:00
parent 4155bf9ce0
commit b89eddc867
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
1 changed files with 9 additions and 0 deletions

View File

@ -2559,6 +2559,15 @@ void NetworkBase::Server_Handle_AUTH(NetworkConnection& connection, NetworkPacke
{
try
{
// RSA technically supports keys up to 65536 bits, so this is the
// maximum signature size for now.
constexpr auto MaxRSASignatureSizeInBytes = 8192;
if (sigsize == 0 || sigsize > MaxRSASignatureSizeInBytes)
{
throw std::runtime_error("Invalid signature size");
}
std::vector<uint8_t> signature;
signature.resize(sigsize);