summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2015-07-13 03:41:33 -0700
committerJake Petroules <jake.petroules@petroules.com>2015-07-17 21:14:28 +0000
commit01f800ae6f8611a4218b7bbf5953dc896cac5767 (patch)
tree5794e5420d71a6bf4ca480e0fe98d93c416a27b6 /src
parent70d84f26bdd35f03ccd6220e3736896fede20c89 (diff)
Add a macro to disable use of potentially dangerous QProcess APIs.
Change-Id: Id1ac19b1f4077ec2ea6f998883653e58ff77a8b6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qprocess.cpp27
-rw-r--r--src/corelib/io/qprocess.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 17079bd1cc..06a4880fdb 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -101,6 +101,19 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
/*!
+ \since 5.6
+
+ \macro QT_NO_PROCESS_COMBINED_ARGUMENT_START
+ \relates QProcess
+
+ Disables the QProcess::start() overload taking a single string.
+ In most cases where it is used, the user intends for the first argument
+ to be treated atomically as per the other overload.
+
+ \sa start()
+*/
+
+/*!
\class QProcessEnvironment
\inmodule QtCore
@@ -2262,7 +2275,20 @@ static QStringList parseCombinedArgString(const QString &program)
After the \a command string has been split and unquoted, this function
behaves like the overload which takes the arguments as a string list.
+ You can disable this overload by defining \c
+ QT_NO_PROCESS_COMBINED_ARGUMENT_START when you compile your applications.
+ This can be useful if you want to ensure that you are not splitting arguments
+ unintentionally, for example. In virtually all cases, using the other overload
+ is the preferred method.
+
+ On operating systems where the system API for passing command line
+ arguments to a subprocess natively uses a single string (Windows), one can
+ conceive command lines which cannot be passed via QProcess's portable
+ list-based API. In these rare cases you need to use setProgram() and
+ setNativeArguments() instead of this function.
+
*/
+#if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START)
void QProcess::start(const QString &command, OpenMode mode)
{
QStringList args = parseCombinedArgString(command);
@@ -2277,6 +2303,7 @@ void QProcess::start(const QString &command, OpenMode mode)
start(prog, args, mode);
}
+#endif
/*!
\since 5.0
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 21421e1184..f95358250e 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -147,7 +147,9 @@ public:
virtual ~QProcess();
void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite);
+#if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START)
void start(const QString &command, OpenMode mode = ReadWrite);
+#endif
void start(OpenMode mode = ReadWrite);
bool open(OpenMode mode = ReadWrite) Q_DECL_OVERRIDE;