Blame 0006-Don-t-crash-when-setmntent-returns-NULL.patch
|
Rex Dieter |
8acc3d |
From ca59eb345cfef368242929ea33beca4bff837e9d Mon Sep 17 00:00:00 2001
|
|
Rex Dieter |
8acc3d |
From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com>
|
|
Rex Dieter |
8acc3d |
Date: Thu, 18 Sep 2014 16:54:26 +0200
|
|
Rex Dieter |
adf30a |
Subject: [PATCH 06/30] Don't crash when setmntent returns NULL
|
|
Rex Dieter |
8acc3d |
|
|
Rex Dieter |
8acc3d |
setmntent can fail when there's no /etc/mtab file for instance and
|
|
Rex Dieter |
8acc3d |
passing NULL pointer to getmntent crashes, so we need to return when
|
|
Rex Dieter |
8acc3d |
this happens.
|
|
Rex Dieter |
8acc3d |
---
|
|
Rex Dieter |
8acc3d |
server/src/utils.cpp | 3 +++
|
|
Rex Dieter |
8acc3d |
1 file changed, 3 insertions(+)
|
|
Rex Dieter |
8acc3d |
|
|
Rex Dieter |
8acc3d |
diff --git a/server/src/utils.cpp b/server/src/utils.cpp
|
|
Rex Dieter |
8acc3d |
index b04a812..b51c330 100644
|
|
Rex Dieter |
8acc3d |
--- a/server/src/utils.cpp
|
|
Rex Dieter |
8acc3d |
+++ b/server/src/utils.cpp
|
|
Rex Dieter |
8acc3d |
@@ -179,6 +179,9 @@ QString Utils::getDirectoryFileSystem(const QString &directory)
|
|
Rex Dieter |
8acc3d |
QString bestMatchFS;
|
|
Rex Dieter |
8acc3d |
|
|
Rex Dieter |
8acc3d |
FILE *mtab = setmntent("/etc/mtab", "r");
|
|
Rex Dieter |
8acc3d |
+ if (!mtab) {
|
|
Rex Dieter |
8acc3d |
+ return QString();
|
|
Rex Dieter |
8acc3d |
+ }
|
|
Rex Dieter |
8acc3d |
while (mntent *mnt = getmntent(mtab)) {
|
|
Rex Dieter |
8acc3d |
if (qstrcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0) {
|
|
Rex Dieter |
8acc3d |
continue;
|
|
Rex Dieter |
8acc3d |
--
|
|
Rex Dieter |
adf30a |
2.1.0
|
|
Rex Dieter |
8acc3d |
|