From bf96f9e55e270cd2eebc2fb2c480d104667fed47 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 26 Jan 2023 10:39:12 +0100 Subject: [PATCH] replaced malloc with strcpy with strdup heh --- src/core/lib/decrypter.c | 12 +++--------- src/logger/lib/logger.c | 3 +-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/lib/decrypter.c b/src/core/lib/decrypter.c index e4947d1..428f3e7 100644 --- a/src/core/lib/decrypter.c +++ b/src/core/lib/decrypter.c @@ -63,16 +63,10 @@ outputFlags decryptText(char *text, char *keyNew) char *textBuffer = malloc(1); int textKeyChainLength; int *textKeyChain; - char *key = malloc(strlen(keyNew) + 1); + char *key = strdup(keyNew); //COPY keyNew TO key int *encryptedTextKeyChain; - char *usedText = malloc(strlen(text) + 1); - char *usedTextCopy = usedText; - - //COPY keyNew TO key - strcpy(key, keyNew); - - //COPY text TO usedText - strcpy(usedText, text); + char *usedText = strdup(text); //COPY text TO usedText + char *usedTextCopy = usedText; //TODO: wtf //GET LENGTH OF returningText AND textKeyChain for (int i = 0; i < (int) strlen(usedText); i++) diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 82fa14a..c675d9c 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -79,8 +79,7 @@ logFile initLogger(char *directoryPath) //CREATE SYMLINK sprintf(latestBuffer, LOG_LATEST_FORMATTING, WRITE_DIR, LOG_LATEST); //GENERATE LATEST.log PATH - latestFilePath = malloc(strlen(filePath) + 1); - strcpy(latestFilePath, filePath); + latestFilePath = strdup(filePath); if (access(latestBuffer, R_OK) == 0) { unlink(latestBuffer); } //REMOVE SYMLINK IF IT ALREADY EXISTS (void) (symlink(latestFilePath + (strlen(WRITE_DIR) + 1), latestBuffer) + 1); //TODO: Try to create some function for processing exit value //CREATE