This patch tries to sanitize the types of our size parameters across our read and write code, which is currently fairly inconsistent (using int, uint, size_t...), by using size_t everywhere. Since in Blender file themselves we can only store chunk of size MAX_INT, added some asserts to ensure that as well.
See T79561: Sanitize size handling in write code for details.