From 35959a43938edc835c59741aac8127bc132591d0 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 25 May 2022 17:51:57 +0200 Subject: [PATCH] changed textKeyChain generation > fixed possible buffer overflow --- src/lib/misc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/misc.c b/src/lib/misc.c index 18b27b8..2b5dbe2 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -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)]; } } }