Skip to content
  • Philip Withnall's avatar
    gfileutils: Add a missing ftruncate() call when writing files · addda9e7
    Philip Withnall authored and Philip Withnall's avatar Philip Withnall committed
    
    
    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: default avatarPhilip Withnall <pwithnall@endlessos.org>
    
    Fixes: #3144
    
    (Backport 2.78: Unmark new translatable string as translatable, to avoid
    adding need for translations.)
    addda9e7