Skip to content

gfileutils: Add a missing ftruncate() call when writing files

When calling g_file_set_contents_full() without G_FILE_SET_CONTENTS_CONSISTENT, the file is written by opening it, write()ing to it, then closing it.

This is fine as long as the file is not longer than the new content you want to set its contents to. If it is, the last bit of the old content remains, because g_file_set_contents_full() was missing an ftruncate() call.

Fix that, and change the tests to catch truncation failures in future.

Signed-off-by: Philip Withnall pwithnall@endlessos.org

Fixes: #3144 (closed)

Closes #3144 (closed)

Merge request reports