Fix exivextractor crash with malformed files
ClosedPublic

Authored by astippich on Apr 28 2019, 1:16 PM.

Details

Summary

Prevent a segfault by explicitly checking everywhere
for valid entries.

BUG: 405210

Diff Detail

Repository
R286 KFileMetaData
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
astippich created this revision.Apr 28 2019, 1:16 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptApr 28 2019, 1:16 PM
Restricted Application added subscribers: Baloo, kde-frameworks-devel. · View Herald Transcript
astippich requested review of this revision.Apr 28 2019, 1:16 PM
bruns added inline comments.Apr 28 2019, 1:23 PM
src/extractors/exiv2extractor.cpp
299–300

!it->empty() ?

astippich added inline comments.Apr 28 2019, 1:36 PM
src/extractors/exiv2extractor.cpp
299–300

Unfortunately, empty() does not exist. Same was done in https://phabricator.kde.org/D16165

bruns added inline comments.Apr 28 2019, 2:26 PM
src/extractors/exiv2extractor.cpp
299–300

Yes, probably as count() is O(1).

306–307

Shouldn't there be a check here as well? And probably move the ratio.second to after its assignment and immediately return.

astippich updated this revision to Diff 57135.Apr 28 2019, 3:01 PM
  • also check for altitude ref
astippich marked an inline comment as done.Apr 28 2019, 3:02 PM
astippich added inline comments.
src/extractors/exiv2extractor.cpp
306–307

Yep, forgot

bruns added a comment.Apr 28 2019, 7:38 PM

Otherwise, LGTM

src/extractors/exiv2extractor.cpp
306–307

Can you add a line break here as well?

astippich updated this revision to Diff 57157.Apr 29 2019, 5:43 AM
astippich marked an inline comment as done.
  • add line break
astippich marked 2 inline comments as done.Apr 29 2019, 5:43 AM
bruns accepted this revision.Apr 29 2019, 11:24 AM
This revision is now accepted and ready to land.Apr 29 2019, 11:24 AM
ngraham accepted this revision.Apr 29 2019, 5:26 PM
This revision was automatically updated to reflect the committed changes.