Bug 323693

Summary: Kate does not truncate files in write protected folders
Product: [Applications] kate Reporter: Martin Walch <walch.martin>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: critical CC: digimer, emmanuel.lepage, kevin.kofler, michal.humpula, peter.maloney
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 4.12.5

Description Martin Walch 2013-08-18 22:40:36 UTC
When saving to a file with write permissions in a directory without write permissions, the content of the file will be overwritten, but without truncating.  However, this behaviour is not reflected in the user interface. You do not see the garbage before EOF unless you reload it.

Reproducible: Always

Steps to Reproduce:
1. mkdir foo
2. echo 1234567890 > foo/bar
3. chmod 555 foo
4. kate foo/bar
5. hit Ctrl+A
6. hit Del
7. type ABC
8. hit Ctrl+S

(9. hit F5)

Actual Results:  
What is saved is

ABC4567890\n


Expected Results:  
ABC
Comment 1 Michal Humpula 2013-12-31 13:31:28 UTC
Git commit cb28209081def580849b194620892ef489be55dd by Michal Humpula.
Committed on 29/12/2013 at 14:41.
Pushed by michalhumpula into branch 'master'.

don't forget to truncate file if we are overwriting

REVIEW: 114724

M  +3    -2    part/buffer/katetextbuffer.cpp
M  +35   -0    tests/katetextbuffertest.cpp
M  +1    -0    tests/katetextbuffertest.h

http://commits.kde.org/kate/cb28209081def580849b194620892ef489be55dd
Comment 2 Emmanuel Lepage Vallée 2014-01-01 21:24:17 UTC
*** Bug 319679 has been marked as a duplicate of this bug. ***
Comment 3 Rex Dieter 2014-04-06 03:25:01 UTC
*** Bug 333086 has been marked as a duplicate of this bug. ***
Comment 4 Rex Dieter 2014-04-06 03:30:00 UTC
As far as I can tell, users are still reporting corruption in (stable) 4.12 branch, the fix was never backported.  Can it?
Comment 5 Kevin Kofler 2014-04-06 20:24:07 UTC
This is clearly a data loss bug, why was that critical fix not backported to the stable branch immediately?
Comment 6 Dominik Haumann 2014-04-07 08:27:07 UTC
@Dieter: Yes, the patch is safe. Will you do it?
@Kevin: Why was it never backported? Obviously simply noone did it, probably out of being too busy or it simply slipped.
Comment 7 Dominik Haumann 2014-04-07 20:30:12 UTC
Git commit 874b16040ed6706bdf1be5917657f2278894776e by Dominik Haumann.
Committed on 07/04/2014 at 20:30.
Pushed by dhaumann into branch 'KDE/4.12'.

backport: truncate files when opening for writing

This backport was kind of requested in bug #323693.

FIXED-IN: 4.12.4

M  +3    -2    part/buffer/katetextbuffer.cpp

http://commits.kde.org/kate/874b16040ed6706bdf1be5917657f2278894776e
Comment 8 Kevin Kofler 2014-04-07 22:00:07 UTC
Unfortunately, 4.12.4 was already released, so this will be only in 4.12.5 (scheduled for April 29 (tagging on April 24) according to the schedule).
Comment 9 digimer 2014-04-07 23:22:45 UTC
Given the severity of this bug, shouldn't a new release be pushed out as soon as is possible?

I corrupted two files thanks to this.
Comment 10 Dominik Haumann 2014-04-08 12:51:13 UTC
It's up to the distributions to ship these kind of updates. It will come eventually.
Comment 11 Martin Walch 2014-09-20 10:10:54 UTC
*** Bug 339143 has been marked as a duplicate of this bug. ***