diff options
author | Seppia <nonso@insicuri.net> | 2016-06-12 16:44:31 +0200 |
---|---|---|
committer | Seppia <nonso@insicuri.net> | 2016-06-12 16:44:31 +0200 |
commit | 6d63e5552ae3199e83536fb631a15df1fa7d4e96 (patch) | |
tree | cf1a3a62cf303973dd9288b9d13d5143655fbc03 | |
parent | fa813ece17a99fb0a0a177ad5a0bf4f11d9629d7 (diff) | |
download | onetimebluh-6d63e5552ae3199e83536fb631a15df1fa7d4e96.tar.gz onetimebluh-6d63e5552ae3199e83536fb631a15df1fa7d4e96.tar.bz2 onetimebluh-6d63e5552ae3199e83536fb631a15df1fa7d4e96.zip |
added input file existance check in function xor
-rw-r--r-- | onetimebluh.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/onetimebluh.c b/onetimebluh.c index 3516cd3..e6366f0 100644 --- a/onetimebluh.c +++ b/onetimebluh.c @@ -1,7 +1,10 @@ -#include<stdio.h> -#include<stdlib.h> -#include<getopt.h> -#include<openssl/rand.h> +#include <stdio.h> +#include <stdlib.h> +#include <getopt.h> +#include <openssl/rand.h> +#include <unistd.h> +#include <errno.h> +#include <error.h> void xor(char* mess, char* keyf, char* outp); void keyrand(int nb, char* outp); @@ -91,6 +94,12 @@ void xor(char* mess, char* keyf, char* outp) { char* defoutp = "critt"; + if (access(mess, F_OK) == -1) { + error(errno, errno, mess); + } else if (access(keyf, F_OK) == -1) { + error(errno, errno, keyf); + } + if (outp == NULL) { printf("WARNING no output name specified using default value 'critt' \n"); outp = defoutp; |