Commit 925b6f0e authored by Seppia's avatar Seppia

Pad too small check

Adds check for pad size relatively to input size and exit with an
error when pad is smaller.
parent f6123e01
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment