Fix (unlikely) integer overflow error in writedata(..)
The range check was applied before padding up, in the unlikely case sizes (INT_MAX - 2) or (INT_MAX - 1) were passed in, the value overflow into a negative integer.
This commit is contained in:
@@ -704,14 +704,14 @@ static void writedata(WriteData *wd, int filecode, size_t len, const void *adr)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Align to 4 (writes uninitialized bytes in some cases). */
|
||||
len = (len + 3) & ~size_t(3);
|
||||
|
||||
if (len > INT_MAX) {
|
||||
BLI_assert_msg(0, "Cannot write chunks bigger than INT_MAX.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Align to 4 (writes uninitialized bytes in some cases). */
|
||||
len = (len + 3) & ~size_t(3);
|
||||
|
||||
/* Initialize #BHead. */
|
||||
bh.code = filecode;
|
||||
bh.old = adr;
|
||||
|
||||
Reference in New Issue
Block a user