Review Request 128277: Fix unsafe KDirModelDirNode* casts
Rob Wu
rob at robwu.nl
Fri Jul 1 11:29:21 UTC 2016
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128277/
-----------------------------------------------------------
(Updated July 1, 2016, 1:29 p.m.)
Status
------
This change has been marked as submitted.
Review request for KDE Frameworks.
Changes
-------
Submitted with commit 04b0681d0c1f7e294bae8039cf2a8b720ed919f0 by Aleix Pol on behalf of Rob Wu to branch master.
Repository: kio
Description
-------
Replace two isDir debug assertions with conditionals, because
there is no guarantee that the parameter is a directory.
Diffs
-----
autotests/kdirmodeltest.cpp 1a14a01
src/widgets/kdirmodel.cpp eab0121
Diff: https://git.reviewboard.kde.org/r/128277/diff/
Testing
-------
To test, I first configured ASAN by passing the following to cmake:
`-DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=undefined"`
KDirModel::index was tested as follows:
```
make kdirmodeltest
ASAN_OPTIONS=detect_leaks=0 ./autotests/kdirmodeltest testIndex
```
KDirModel::fetchMore is tested as follows (manually):
1. Create `a.out` as follows:
```c++
// g++ `pkg-config --cflags --libs Qt5Widgets` main.cpp -fPIC -fsanitize=address
#include <QApplication>
#include <QFileDialog>
#include <QTemporaryDir>
int main(int argc, char **argv) {
QTemporaryDir tempDir;
QFile(tempDir.path() + "/filename.tex").open(QIODevice::WriteOnly);
QApplication app(argc, argv);
QStringList filesNames = QFileDialog::getOpenFileNames(
Q_NULLPTR, "Open File", tempDir.path(), "TeX files (*.tex)");
return app.exec();
}
```
2. Run it. In the file dialog, type "./".
3. A dropdown shows the files in the directory ("filename.tex").
4. Press arrow down. Now the filename will be matched and NOTHING should happen.
Before this patch, step 4 would crash; This is a reduced test case based on
a crash when I tried to save my work in TexMaker's (Save As dialog).
Thanks,
Rob Wu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160701/a3d59913/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list