]>
Commit | Line | Data |
---|---|---|
8a8f9fb3 AM |
1 | From ca59eb345cfef368242929ea33beca4bff837e9d Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com> | |
3 | Date: Thu, 18 Sep 2014 16:54:26 +0200 | |
4 | Subject: [PATCH 06/30] Don't crash when setmntent returns NULL | |
5 | ||
6 | setmntent can fail when there's no /etc/mtab file for instance and | |
7 | passing NULL pointer to getmntent crashes, so we need to return when | |
8 | this happens. | |
9 | --- | |
10 | server/src/utils.cpp | 3 +++ | |
11 | 1 file changed, 3 insertions(+) | |
12 | ||
13 | diff --git a/server/src/utils.cpp b/server/src/utils.cpp | |
14 | index b04a812..b51c330 100644 | |
15 | --- a/server/src/utils.cpp | |
16 | +++ b/server/src/utils.cpp | |
17 | @@ -179,6 +179,9 @@ QString Utils::getDirectoryFileSystem(const QString &directory) | |
18 | QString bestMatchFS; | |
19 | ||
20 | FILE *mtab = setmntent("/etc/mtab", "r"); | |
21 | + if (!mtab) { | |
22 | + return QString(); | |
23 | + } | |
24 | while (mntent *mnt = getmntent(mtab)) { | |
25 | if (qstrcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0) { | |
26 | continue; | |
27 | -- | |
28 | 2.1.0 | |
29 |