fix crashing with duplicate entries
ClosedPublic

Authored by sandsmark on Feb 15 2018, 1:59 PM.

Details

Summary

some zip files apparently can have duplicate entry names, which weren't handled correctly.

Test Plan

created a unit test in a separate commit.

Diff Detail

Repository
R243 KArchive
Lint
Lint Skipped
Unit
Unit Tests Skipped
sandsmark created this revision.Feb 15 2018, 1:59 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 15 2018, 1:59 PM
sandsmark requested review of this revision.Feb 15 2018, 1:59 PM
apol added a subscriber: apol.Feb 15 2018, 2:20 PM
apol added inline comments.
src/karchive.cpp
832–833

Haven't looked at the code yet, but this doesn't make much sense.
Since it's already in the map, we remove it from the map?

Maybe this should remove the return then.

sandsmark updated this revision to Diff 27275.Feb 15 2018, 4:14 PM

actually do the correct thing

sandsmark updated this revision to Diff 27276.Feb 15 2018, 4:17 PM

handle stuff a bit prettier. I don't think there's a "right" way to handle this, so parsing is a bit best-effort, but at least it doesn't crash anymore.

apol added inline comments.Feb 15 2018, 4:18 PM
src/karchive.cpp
829

Cache the value not to query twice?

sandsmark updated this revision to Diff 27286.Feb 15 2018, 7:11 PM

an actual fix, which passes all unit tests.

dfaure requested changes to this revision.Feb 15 2018, 7:55 PM

Thanks for the fix!

src/karchive.cpp
471

Please remove this warning, it's ambiguous at this point what the problem is; better have only one clear warning once we know which case we're in.

472

You can remove this if(), every entry is either a file or a directory, by design.
And the if() confused me, e.g. if it was false, the code below would still talk about an empty file ;). But it can't ever be false, so let's just remove that if().

475

Obviously that means mentioning "path" in this warning, something about that file being a duplicate.

480

If this can happen, since there's no data loss, maybe a qCDebug is enough?
(this also needs to mention "path" of course)

src/kzip.cpp
756

Use multi-arg to avoid issues in case one of these strings contains %1.

.arg(entryName, path, path)
This revision now requires changes to proceed.Feb 15 2018, 7:55 PM
sandsmark updated this revision to Diff 27664.Feb 21 2018, 10:48 AM
sandsmark marked 7 inline comments as done.

fixes to issues raised

sandsmark updated this revision to Diff 27668.Feb 21 2018, 11:00 AM
dfaure accepted this revision.Mar 4 2018, 2:05 PM
This revision is now accepted and ready to land.Mar 4 2018, 2:05 PM
This revision was automatically updated to reflect the committed changes.