Tags ioslave: Do not crash for the "tags:/" URL
ClosedPublic

Authored by marten on Tue, Feb 26, 9:05 PM.

Details

Summary

Bug https://bugs.kde.org/show_bug.cgi?id=400594 was fixed by https://commits.kde.org/baloo/f4dd3f7bab790734b47a31c70fbb68297d4d3062
which checks for the URL starting with "tags://" and considering this to be an invalid URL. This is fine, but the problem is that if the URL "tags:/" is
passed in the string is not long enough and QString::at() asserts. This is seen as a crash of the ioslave every time the right click menu is popped up
in Konqueror (on any sort of view), or from the command line by doing "kioclient5 ls tags:/":

kio_tags(11869) unknown: ASSERT: "uint(i) < uint(size())" in file /usr/include/qt5/QtCore/qstring.h, line 934

#10 0x00007f3d402fe0bc in qt_assert(char const*, char const*, int) () from /usr/lib64/libQt5Core.so.5
#11 0x00007f3d36eec337 in QString::at (i=6, this=0x7ffd4531d8a8) at /usr/include/qt5/QtCore/qstring.h:934
#12 Baloo::TagsProtocol::parseUrl (this=this@entry=0x7ffd4531da60, url=..., flags=...) at baloo/baloo/src/kioslaves/tags/kio_tags.cpp:299
#13 0x00007f3d36eedda6 in Baloo::TagsProtocol::listDir (this=0x7ffd4531da60, url=...) at baloo/baloo/src/kioslaves/tags/kio_tags.cpp:59
#14 0x00007f3d3663e1de in KIO::SlaveBase::dispatch (this=0x7ffd4531da70, command=71, data=...) at kio/src/core/slavebase.cpp:1176
#15 0x00007f3d3663f78e in KIO::SlaveBase::dispatchLoop (this=0x7ffd4531da70) at kio/src/core/slavebase.cpp:325
#16 0x00007f3d36ef1943 in kdemain (argc=<optimized out>, argv=<optimized out>) at baloo/baloo/src/kioslaves/tags/kio_tags.cpp:486

The QString::at() needs to be guarded by a length check.

Test Plan

Built Baloo with this change, verified that no crash happens when using the URL "tags:/"

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
marten created this revision.Tue, Feb 26, 9:05 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptTue, Feb 26, 9:05 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
marten requested review of this revision.Tue, Feb 26, 9:05 PM
ngraham accepted this revision.Tue, Feb 26, 10:43 PM
This revision is now accepted and ready to land.Tue, Feb 26, 10:43 PM
This revision was automatically updated to reflect the committed changes.
bruns added a subscriber: bruns.Wed, Feb 27, 6:48 PM

Thanks for the fix!
I think it is quite alarming that code causing a crash landed in the repo without review ...