changed textKeyChain generation > fixed possible buffer overflow

This commit is contained in:
Václav Šmejkal 2022-05-25 17:51:57 +02:00
parent 4534ec7521
commit 35959a4393

View File

@ -151,13 +151,13 @@ void generateTextKeyChain(char key[], int *textKeyChain, int textKeyChainSize)
//FILL textKeyChain
if ((numberBuffer + 1) % 3 == 0)
{
textKeyChain[i] = key[numberBuffer] * key[numberBuffer + 1];
textKeyChain[i] = key[numberBuffer] * key[numberBuffer + (i < textKeyChainSize)];
} else if ((numberBuffer + 1) % 2 == 0)
{
textKeyChain[i] = key[numberBuffer] - key[numberBuffer + 1];
textKeyChain[i] = key[numberBuffer] - key[numberBuffer + (i < textKeyChainSize)];
} else
{
textKeyChain[i] = key[numberBuffer] + key[numberBuffer + 1];
textKeyChain[i] = key[numberBuffer] + key[numberBuffer + (i < textKeyChainSize)];
}
}
}