- Validate the plugin name of the package at install time to prevent the

injection of bad characters into the path when the package is removed.


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=846853
This commit is contained in:
Richard J. Moore 2008-08-14 09:03:24 +00:00
parent 4271ebeba9
commit 014c81a040

View File

@ -22,6 +22,7 @@
#include <QDir>
#include <QFile>
#include <QRegExp>
#include <KArchiveDirectory>
#include <KArchiveEntry>
@ -272,6 +273,14 @@ bool Package::installPackage(const QString& package,
return false;
}
// Ensure that package names are safe so package uninstall can't inject
// bad characters into the paths used for removal.
QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period.
if ( !validatePluginName.exactMatch(targetName) ) {
kWarning() << "Package plugin name " << targetName << "contains invalid characters";
return false;
}
targetName = packageRoot + '/' + targetName;
if (QFile::exists(targetName)) {
kWarning() << targetName << "already exists";