Review Request 128277: Fix unsafe KDirModelDirNode* casts

Rob Wu rob at robwu.nl
Mon Jun 27 15:01:00 UTC 2016



> On June 27, 2016, 8:29 a.m., David Faure wrote:
> > Ship It!

Thanks. Could you commit it?


- Rob


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128277/#review96881
-----------------------------------------------------------


On June 23, 2016, 4:55 p.m., Rob Wu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/128277/
> -----------------------------------------------------------
> 
> (Updated June 23, 2016, 4:55 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> 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/20160627/e587f8ca/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list