Opened 4 years ago

Closed 4 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 4 years ago by dmik

  • Milestone changed from Qt Enhanced to Qt 4.6.3

comment:2 Changed 4 years ago by dmik

  • Resolution set to fixed
  • Status changed from new to closed

Rudi, thanks for spotting it. Fixed in r761.

Note: See TracTickets for help on using tickets.