summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-11 13:01:09 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-12 12:05:01 +0000
commitf0f456398da65fc36837c0ab66b983a69b6f9e3e (patch)
treeb5c6871752834896312685b42b7b352ea7b88cfe /auto_tests
parent1de8b020cb5f79c3e52a0fb502b5abdbbd20a2f0 (diff)
Check that the save file size isn't larger than our address space.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/file_saving_test.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c
index a5ba7e1f..13a98280 100644
--- a/auto_tests/file_saving_test.c
+++ b/auto_tests/file_saving_test.c
@@ -82,6 +82,8 @@ static void load_data_decrypted(void)
82 int64_t size = ftell(f); 82 int64_t size = ftell(f);
83 fseek(f, 0, SEEK_SET); 83 fseek(f, 0, SEEK_SET);
84 84
85 ck_assert_msg(0 <= size && size <= SIZE_MAX, "file size out of range");
86
85 uint8_t *cipher = (uint8_t *)malloc(size); 87 uint8_t *cipher = (uint8_t *)malloc(size);
86 uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); 88 uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
87 size_t read_value = fread(cipher, sizeof(*cipher), size, f); 89 size_t read_value = fread(cipher, sizeof(*cipher), size, f);