Opened 14 years ago

Closed 14 years ago

#177 closed defect (fixed)

QProcess::startDetached() fails to pass arguments

Reported by: rudi Owned by:
Priority: major Milestone: Qt 4.6.3
Component: QtCore Version: 4.6.2
Severity: high Keywords:
Cc:

Description

In some cases arguments are not passed correctly to the child process. The reason is than QByteArray::size() does not count the trailing zero. Thus the argument strings might be unterminated.

Index: qprocess_os2.cpp
===================================================================
--- qprocess_os2.cpp	(revision 758)
+++ qprocess_os2.cpp	(working copy)
@@ -993,12 +993,12 @@
             // DosStartSession() as it cannot work with high memory
             PSZ pgmNameLow = (PSZ)::_lmalloc(::strlen(programReal) + 1);
             ::strcpy(pgmNameLow, programReal);
-            PSZ argsLow = (PSZ)::_lmalloc(args.size());
-            ::memcpy(argsLow, args, args.size());
+            PSZ argsLow = (PSZ)::_lmalloc(args.size() + 1);
+            ::memcpy(argsLow, args, args.size() + 1);
             PSZ envLow = 0;
             if (!env.isEmpty()) {
-                envLow = (PSZ)::_lmalloc(env.size());
-                ::memcpy(envLow, env, env.size());
+                envLow = (PSZ)::_lmalloc(env.size() + 1);
+                ::memcpy(envLow, env, env.size() + 1);
             }
 #else
             PSZ pgmNameLow = (PSZ)programReal;

Change History (2)

comment:1 Changed 14 years ago by Dmitry A. Kuminov

Milestone: Qt EnhancedQt 4.6.3

comment:2 Changed 14 years ago by Dmitry A. Kuminov

Resolution: fixed
Status: newclosed

Rudi, thanks for spotting it. Fixed in r761.

Note: See TracTickets for help on using tickets.