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