Bug 323693 - Kate does not truncate files in write protected folders
Summary: Kate does not truncate files in write protected folders
Alias: None
Product: kate
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR critical (vote)
Target Milestone: ---
Assignee: KWrite Developers
: 319679 333086 339143 (view as bug list)
Depends on:
Reported: 2013-08-18 22:40 UTC by Martin Walch
Modified: 2014-09-20 10:10 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12.5


Note You need to log in before you can comment on or make changes to this bug.
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


Expected Results:  
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

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

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. ***