Commit b8ef341f authored by Art M. Gallagher's avatar Art M. Gallagher Committed by Karolin Seeger

vfs_fruit: tmsize prevent overflow Force the type during arithmetic in order...

vfs_fruit: tmsize prevent overflow Force the type during arithmetic in order to prevent overflow when summing the Time Machine folder size. Increase the precision to off_t (used for file sizes), leave the overflow error traps but with more precise wording.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13622Signed-off-by: Art M. Gallagher's avatarArt M. Gallagher <[email protected]>
Reviewed-by: Ralph Böhme's avatarRalph Boehme <[email protected]>
Reviewed-by: Jeremy Allison's avatarJeremy Allison <[email protected]>

Autobuild-User(master): Jeremy Allison <[email protected]>
Autobuild-Date(master): Sat Mar  7 01:37:31 UTC 2020 on sn-devel-184

(cherry picked from commit b0ba7cd4)
parent fdc2f7d2
......@@ -4986,15 +4986,21 @@ static bool fruit_tmsize_do_dirent(vfs_handle_struct *handle,
return true;
}
/*
* Arithmetic on 32-bit systems may cause overflow, depending on
* size_t precision. First we check its unlikely, then we
* force the precision into target off_t, then we check that
* the total did not overflow either.
*/
if (bandsize > SIZE_MAX/nbands) {
DBG_ERR("tmsize overflow: bandsize [%zu] nbands [%zu]\n",
DBG_ERR("tmsize potential overflow: bandsize [%zu] nbands [%zu]\n",
bandsize, nbands);
return false;
}
tm_size = bandsize * nbands;
tm_size = (off_t)bandsize * (off_t)nbands;
if (state->total_size + tm_size < state->total_size) {
DBG_ERR("tmsize overflow: bandsize [%zu] nbands [%zu]\n",
DBG_ERR("tm total size overflow: bandsize [%zu] nbands [%zu]\n",
bandsize, nbands);
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment