Check that the save file size isn't larger than our address space.

This commit is contained in:
iphydf 2018-08-11 13:01:09 +00:00
parent 1de8b020cb
commit f0f456398d
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -82,6 +82,8 @@ static void load_data_decrypted(void)
int64_t size = ftell(f); int64_t size = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
ck_assert_msg(0 <= size && size <= SIZE_MAX, "file size out of range");
uint8_t *cipher = (uint8_t *)malloc(size); uint8_t *cipher = (uint8_t *)malloc(size);
uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
size_t read_value = fread(cipher, sizeof(*cipher), size, f); size_t read_value = fread(cipher, sizeof(*cipher), size, f);