diff options
author | Seppia <seppia@seppio.fish> | 2018-07-07 07:46:52 +0200 |
---|---|---|
committer | Seppia <seppia@seppio.fish> | 2018-07-07 07:46:52 +0200 |
commit | 925b6f0ec83ee09b116e3ec9b457e0bf0a5bad9f (patch) | |
tree | 6f1c1dfac6ffef0312c44c0ec1f92e212a7902b3 /src | |
parent | f6123e01a5bbcd809efc7a4546620e6150d4b610 (diff) | |
download | onetimebluh-master.tar.gz onetimebluh-master.tar.bz2 onetimebluh-master.zip |
Adds check for pad size relatively to input size and exit with an
error when pad is smaller.
Diffstat (limited to 'src')
-rw-r--r-- | src/onetimebluh.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/onetimebluh.c b/src/onetimebluh.c index db65a58..c89b7f3 100644 --- a/src/onetimebluh.c +++ b/src/onetimebluh.c @@ -189,6 +189,14 @@ void xor (Opts* opzioni) { mess_size = strlen (input); } + fseek (keyx, 0L, SEEK_END); + int64_t pad_size = ftell (keyx); + + if (pad_size < mess_size) { + eprintf("ERROR: your pad is too small!\n"); + exit (EXIT_FAILURE); + } + char* bytes; if (opzioni->input) { @@ -211,8 +219,6 @@ void xor (Opts* opzioni) { if (opzioni->tear) { - fseek (keyx, 0L, SEEK_END); - int64_t pad_size = ftell (keyx); ftruncate (fileno (keyx), (pad_size - mess_size)); fseek (keyx, 0L, SEEK_END); int64_t new_pad_size = ftell (keyx); |