mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Check that the save file size isn't larger than our address space.
This commit is contained in:
parent
1de8b020cb
commit
f0f456398d
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user