diff --git a/include/misc.h b/include/misc.h index 478a3aa..049e506 100644 --- a/include/misc.h +++ b/include/misc.h @@ -7,6 +7,7 @@ void checkVersion(inputFlags flags); //THIS FUNCTION CHECKS IF LATEST VERSION OF void generateTextKeyChain(char *key, int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION void deallocateOutput(outputFlags flags); //DEALLOCATES flags void checkKey(char *key, inputFlags flags); //CHECKS IF KEY IS VALID +void checkText(char *text, inputFlags flags); //CHECKS IF TEXT IS VALID int countIntLength(int number); //RETURNS LENGTH OF number #endif diff --git a/src/lib/decrypter.c b/src/lib/decrypter.c index cfdd19f..6604268 100644 --- a/src/lib/decrypter.c +++ b/src/lib/decrypter.c @@ -9,6 +9,9 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags) { + //CHECK FOR INVALID text + checkText(text, flags); + //CHECK FOR INVALID key checkKey(keyNew, flags); diff --git a/src/lib/encrypter.c b/src/lib/encrypter.c index e2e207f..5647596 100644 --- a/src/lib/encrypter.c +++ b/src/lib/encrypter.c @@ -10,9 +10,18 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags) { + //CHECK FOR INVALID text + checkText(text, flags); + //CHECK FOR ACTIVE VERSION if (!flags.skipCheck) checkVersion(flags); + if (strcmp(text, "") == 0) + { + if (!flags.noOutput) fprintf(stderr, "No text to encrypt!\n"); + exit(1); + } + //VARIABLES char *key = malloc(getKeyLength()); char *returningText; diff --git a/src/lib/misc.c b/src/lib/misc.c index a43b2ee..f7b89de 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -182,6 +182,15 @@ void checkKey(char *key, inputFlags flags) } } +void checkText(char *text, inputFlags flags) +{ + if (strcmp(text, "") == 0) + { + if (!flags.noOutput) fprintf(stderr, "No text to encrypt!\n"); + exit(1); + } +} + int countIntLength(int number) { int returning = 1;