diff options
author | Matthew Dawson <matthew@mjdsystems.ca> | 2015-12-29 00:51:16 -0500 |
---|---|---|
committer | Matthew Dawson <matthew@mjdsystems.ca> | 2015-12-29 19:34:38 -0500 |
commit | 55bf90ff787f4e84947a5df833f66082e54016df (patch) | |
tree | 8d3705c05e0dc09b4d3c4c1801afd1998378f13d | |
parent | 837edaabc446b946fca5f318ae53ad305eab13fd (diff) | |
download | kconfig-55bf90ff787f4e84947a5df833f66082e54016df.tar.gz kconfig-55bf90ff787f4e84947a5df833f66082e54016df.tar.bz2 |
Ensure group is unescaped properly in kconf_update.
During a kconf_update run, an invalid group name may be treated as correct
even though the name failed to unescape. This leads the group name to be
a null character, which will fail.
If the unescape failed, return that failure status instead. This should have
no impact, as the previous result would have been wrong anyways. Now a
more useful diagnostic will be returned instead.
Update the unit tests to ensure this issue is tested in the future.
Found in Coverity issue 258087.
REVIEW: 126556
-rw-r--r-- | autotests/test_kconfigutils.cpp | 6 | ||||
-rw-r--r-- | src/kconf_update/kconfigutils.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp index 0946cf8a..576ef784 100644 --- a/autotests/test_kconfigutils.cpp +++ b/autotests/test_kconfigutils.cpp @@ -57,6 +57,12 @@ void TestKConfigUtils::testParseGroupString_data() << QStringList() << false ; + + QTest::newRow("invalid-escape-string") + << "[a\\z]" + << QStringList() + << false + ; } void TestKConfigUtils::testParseGroupString() diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 02b3f0a9..0a2741ea 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -46,7 +46,7 @@ KConfigGroup openGroup(KConfig *config, const QStringList &lst) QStringList parseGroupString(const QString &_str, bool *ok, QString *error) { QString str = unescapeString(_str.trimmed(), ok, error); - if (!ok) { + if (!*ok) { return QStringList(); } |