summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeppia <seppia@seppio.fish>2018-07-07 07:46:52 +0200
committerSeppia <seppia@seppio.fish>2018-07-07 07:46:52 +0200
commit925b6f0ec83ee09b116e3ec9b457e0bf0a5bad9f (patch)
tree6f1c1dfac6ffef0312c44c0ec1f92e212a7902b3
parentf6123e01a5bbcd809efc7a4546620e6150d4b610 (diff)
downloadonetimebluh-0.3.1.tar.gz
onetimebluh-0.3.1.tar.bz2
onetimebluh-0.3.1.zip
Pad too small checkHEADv0.3.1master
Adds check for pad size relatively to input size and exit with an error when pad is smaller.
-rw-r--r--src/onetimebluh.c10
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);