From f7d8bb052e42dba21026587ea67e4f9a24ffe1f5 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 19 Jul 2022 17:18:00 +0200 Subject: [PATCH] fixed decryption bug basically, the buffer had some content after allocation in it, so it screwed up last character in 1/10 cases --- src/lib/decrypter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/decrypter.c b/src/lib/decrypter.c index 5ad331a..b09b587 100644 --- a/src/lib/decrypter.c +++ b/src/lib/decrypter.c @@ -87,6 +87,12 @@ outputFlags decryptText(char *text, char *keyNew) textBuffer = malloc(numberBuffer + 1); } + //CLEAN (POSSIBLY EXISTING) JUNK in textBuffer + for (int i = 0; i <= numberBuffer; i++) + { + textBuffer[i] = '\0'; + } + //LOAD textBuffer for (int j = 0; j < (int) strlen(text); j++) {