Skip to content

gfileutils: Fix g_file_get_contents() silent under-read of large files when off_t is wider than size_t

Joseph Nuzman requested to merge jnuzman/glib:large-file-issue3 into main

On certain platforms where file size (off_t) can be truncated when assigning to gsize, get_contents_regfile() may use the truncated size as the size to read. Add an explicit check to raise an error in such cases.

G_FILE_ERROR_FAILED will be raised in this case, aligning with behavior for other cases.

This generally affects 32-bit non-Win32 platforms.

Merge request reports