aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamarque V. Souza <lamarque@gmail.com>2011-04-22 05:44:08 (GMT)
committerLamarque V. Souza <lamarque@gmail.com>2011-04-22 05:45:56 (GMT)
commita789bceeb1a62fb4d1b6ec9246f1e98fd96e6921 (patch)
tree58e798ca8cc642759df9fbd4c2e0cbd676815b50
parent0c57ad428282ef1d42eaaaba1267f45fd9b158f2 (diff)
Add some checks to Solid's Wicd backend to prevent crash.
BUG: 271408 FIXED-IN: 4.6.3 (cherry picked from commit fc7011b1d8454c6378d88ea870c341d1a3d96374)
-rw-r--r--solid/wicd/wirednetworkinterface.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/solid/wicd/wirednetworkinterface.cpp b/solid/wicd/wirednetworkinterface.cpp
index a2a7959..f9ee597 100644
--- a/solid/wicd/wirednetworkinterface.cpp
+++ b/solid/wicd/wirednetworkinterface.cpp
@@ -145,15 +145,34 @@ QString WicdWiredNetworkInterface::hardwareAddress() const
// Let's parse ifconfig here
QProcess ifconfig;
-
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ qputenv("PATH", QString("/bin:/usr/bin:/sbin:/usr/sbin:" + env.value("PATH")).toAscii());
+ qputenv("LC_ALL", "C");
ifconfig.start(QString("ifconfig %1").arg(uni()));
- ifconfig.waitForFinished();
- QString result = ifconfig.readAllStandardOutput();
+ // ifconfig is not installed or not found in PATH.
+ if (!ifconfig.waitForStarted()) {
+ return QString();
+ }
+
+ // ifconfig returned a error.
+ if (!ifconfig.waitForFinished()) {
+ return QString();
+ }
+ QString result = ifconfig.readAllStandardOutput();
QStringList lines = result.split('\n');
- return lines.at(0).split("HWaddr ").at(1);
+ // ifconfig returned something.
+ if (lines.count() > 0) {
+ QStringList result = lines.at(0).split("HWaddr ");
+
+ // MAC address not found.
+ if (result.count() > 1)
+ return result.at(1);
+ }
+
+ return QString();
}
int WicdWiredNetworkInterface::bitRate() const