From ef4f9f5084c6912fadcf074f05e1adb626933855 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 24 May 2022 18:45:44 +0200 Subject: [PATCH] reverted the sizeof removing I have no idea --- src/lib/decrypter.c | 10 +++++----- src/lib/encrypter.c | 8 ++++---- src/lib/misc.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/decrypter.c b/src/lib/decrypter.c index a2ec8b8..577c4b5 100644 --- a/src/lib/decrypter.c +++ b/src/lib/decrypter.c @@ -33,16 +33,16 @@ outputFlags decryptText(char *text, char *key, inputFlags flags) } //SET LENGTH (numberBuffer) - returningText = malloc(numberBuffer); - textKeyChain = malloc(numberBuffer); - int encryptedTextKeyChain[numberBuffer]; + returningText = malloc(sizeof(char) * numberBuffer); + textKeyChain = malloc(sizeof(int) * numberBuffer); + int encryptedTextKeyChain[sizeof(int) * numberBuffer]; textKeyChainLength = numberBuffer; //LOAD textKeyChain generateTextKeyChain(key, textKeyChain, numberBuffer); //LOAD encryptedTextKeyChain - for (int i = 0; i < sizeof(encryptedTextKeyChain) / sizeof(int); i++) + for (int i = 0; i < (sizeof(encryptedTextKeyChain) / sizeof(int)); i++) { numberBuffer = 0; @@ -54,7 +54,7 @@ outputFlags decryptText(char *text, char *key, inputFlags flags) numberBuffer++; } - textBuffer = malloc(numberBuffer); + textBuffer = malloc(sizeof(char) * numberBuffer); //LOAD textBuffer for (int j = 0; j < strlen(text); j++) diff --git a/src/lib/encrypter.c b/src/lib/encrypter.c index 21a9e22..44f4ce3 100644 --- a/src/lib/encrypter.c +++ b/src/lib/encrypter.c @@ -14,10 +14,10 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags) if (!flags.skipCheck) checkVersion(flags); //VARIABLES - char *key = malloc(getKeyLength()); + char *key = malloc(sizeof(char) * getKeyLength()); char *returningText; char *textBuffer; - int *textKeyChain = malloc(strlen(text)); + int *textKeyChain = malloc(sizeof(int) * strlen(text)); int numberBuffer; FILE *fileBuffer; @@ -79,13 +79,13 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags) } //ALLOCATE returningText (WITH THE SEPARATORS) - returningText = malloc(numberBuffer + strlen(text) - 1); + returningText = malloc(sizeof(char) * numberBuffer + strlen(text) - 1); strcpy(returningText, ""); //LOAD returningText for (int i = 0; i < strlen(text); i++) { - numberBuffer = countIntLength(textKeyChain[i]); + numberBuffer = sizeof(int) * countIntLength(textKeyChain[i]); if (i != 0) { diff --git a/src/lib/misc.c b/src/lib/misc.c index d332758..d6674e8 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -59,7 +59,7 @@ void checkVersion(inputFlags flags) //COUNT LENGTH OF buffer fileBuffer = fopen(VERSIONS_NAME, "r"); fseek(fileBuffer, 0, SEEK_END); - buffer = malloc(ftell(fileBuffer)); + buffer = malloc(sizeof(char) * ftell(fileBuffer)); fclose(fileBuffer); //SET fileBuffer