Fix double delete on broken files

Authored by aacid on Apr 14 2019, 4:08 PM.

Description

Fix double delete on broken files

Summary:
findOrCreate has some code that tries to recover broken files.

That code will delete an empty file if later it looks like it should be a directory.

The problem is that that code, was doing

entry = rootDir->get(path)
if (entry is not dir and it's 0 size) {
rootDir->remove(entry)
delete entry;
}

But unfortunately get() and remove() are not equally stubborn.

get will try to see if the path lives in a subdir while remove only will remove entries in the exact dir.

So it might happen that the old code did call remove() on the root dir but that did nothing since the entry didn't belong to the root dir.

This failure would result in a double delete when the dir that actually contains the entry would be deleted.

This patch introduces a private get that will also return which directory entry exactly lives on so remove succeeds and no double delete happens.

Reviewers: dfaure

Reviewed By: dfaure

Subscribers: dfaure, kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D20519

Details

Committed
aacidApr 14 2019, 7:14 PM
Reviewer
dfaure
Differential Revision
D20519: Fix double delete on broken files
Parents
R243:28a43c285edf: Disallow copy of KArchiveDirectoryPrivate and KArchivePrivate
Branches
Unknown
Tags
Unknown