diff options
-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); |