Bug 339143

Summary: corrupt file saved when not owner of the directory
Product: [Applications] kate Reporter: peter.maloney
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: walch.martin
Priority: NOR    
Version: 3.12.4   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description peter.maloney 2014-09-17 12:02:53 UTC
Tile corruption happens when you shorten a file you saved already in kate and save again. The old ending appears at the end of the file. I don't know what other types of damage can occur.

Reproducible: Always

Steps to Reproduce:
1. Make a directory owned by root. Make a file there owned by your user.
    root@here # mkdir ~you/ownedbyroot
    root@here # touch ~you/ownedbyroot/thefile
    root@here # chown you ~you/ownedbyroot/thefile
2. Open the file with Kate as you, writing the content "12345", and save it.
3. Change the content with Kate to "999", and save it.
4. cat ~you/ownedbyroot/thefile


Actual Results:  
Step 4 says "99945" but should say "999". In Kate, you still see "999" though. The actual file content is wrong, so the file is corrupt.
Comment 1 Martin Walch 2014-09-20 10:10:54 UTC
As Kate cannot create a new file in the same directory, it writes into the existing file, but does not truncate it first.

This has been fixed in 3.12.5. If switching to a newer version is infeasible you can try asking your distribution maintainers to apply the fix to their repositories of 3.12.4.

Of course, if you still see the bug with newer versions of Kate, feel free to reopen this bug.

*** This bug has been marked as a duplicate of bug 323693 ***