Prevent index out of range in case of empty or malformed filename
ClosedPublic

Authored by ahartmetz on Nov 23 2017, 2:53 PM.

Details

Summary

Prevent index out of range in case of empty or malformed filename

The Akonadi cache on this computer somehow has an external file missing. Without this change, the IMAP agent crashes on every attempt to start it.

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahartmetz created this revision.Nov 23 2017, 2:53 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptNov 23 2017, 2:53 PM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript
ahartmetz added a comment.EditedNov 23 2017, 2:56 PM

Maybe it is better to return an empty string in this case but I don't know. Otherwise I might thave pushed this directly. In the case of my missing file, the returned string was the name of the folder <file_db_data>/00/, which generates an error message that the file it tried to open is actually a folder...

knauss added a subscriber: knauss.Nov 23 2017, 3:27 PM

well from the comment above in the code your code makes sence and return an empty string is not intended.

src/private/externalpartstorage.cpp
98

0 is enough here.

ahartmetz added inline comments.Nov 23 2017, 5:19 PM
src/private/externalpartstorage.cpp
98

Replace the whole line with QLatin1Char('0') ? Are you sure? That seems dubious but then I don't know what exactly this code is supposed to do.

knauss added inline comments.Nov 23 2017, 5:34 PM
src/private/externalpartstorage.cpp
98

no i mean replace revPos > 1 with revPos > 0

You are right that the code should return an empty string in case the filename is missing in the payload data. I'll add that in a separate commit since it requires that the situation is correctly handled by all users of this method.

Merging this safety still makes sense in case some other corruption occurs, so please fix the code as Sandro requested.

ahartmetz updated this revision to Diff 23052.Nov 27 2017, 9:24 PM
ahartmetz marked an inline comment as done.

Change second index check to >0

ahartmetz updated this revision to Diff 23053.Nov 27 2017, 9:36 PM

Change base revision

This revision was automatically updated to reflect the committed changes.