fix possible underflow in BlowfishKeyProvider.LenBigNum()

This commit is contained in:
atlimit8
2022-05-18 23:08:30 -05:00
committed by Matthias Mailänder
parent 8ce9e01c1c
commit c56d2c1bbe

View File

@@ -90,8 +90,14 @@ namespace OpenRA.Mods.Cnc.FileFormats
static uint LenBigNum(uint[] n, uint len)
{
var i = len - 1;
while (n[i] == 0) i--;
if (len == 0)
return 0;
var i = len;
while (n[--i] == 0)
if (i == 0)
return 0; // all zero
return i + 1;
}