From b84b8aa7ccf72736ca9a9d3e617e71c5d72bd329 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 26 May 2022 17:19:31 +0200 Subject: [PATCH] added/fixed null characters --- src/lib/decrypter.c | 4 +++- src/lib/encrypter.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/decrypter.c b/src/lib/decrypter.c index 0611f41..6062bdd 100644 --- a/src/lib/decrypter.c +++ b/src/lib/decrypter.c @@ -33,7 +33,7 @@ outputFlags decryptText(char *text, char *key, inputFlags flags) } //SET LENGTH (numberBuffer) - returningText = malloc(numberBuffer); + returningText = malloc(numberBuffer + 1); textKeyChain = malloc(sizeof(int) * numberBuffer); int encryptedTextKeyChain[sizeof(int) * numberBuffer]; textKeyChainLength = numberBuffer; @@ -82,6 +82,8 @@ outputFlags decryptText(char *text, char *key, inputFlags flags) returningText[i] = (char) textKeyChain[i]; } + strcat(returningText, "\0"); + //LOAD output outputFlags output = { diff --git a/src/lib/encrypter.c b/src/lib/encrypter.c index a5ea709..334d697 100644 --- a/src/lib/encrypter.c +++ b/src/lib/encrypter.c @@ -14,7 +14,7 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags) if (!flags.skipCheck) checkVersion(flags); //VARIABLES - char *key = malloc(getKeyLength() + 1); + char *key = malloc(getKeyLength()); char *returningText; char *textBuffer; int *textKeyChain = malloc(sizeof(int) * strlen(text)); @@ -107,6 +107,8 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags) } } + strcat(returningText, "\0"); + //LOAD output outputFlags output = {