[X2Go-Commits] [x2goclient] 21/217: x2goclient.cpp: create new argv array on the heap instead of on the stack.

git-admin at x2go.org git-admin at x2go.org
Sat Aug 27 19:24:17 CEST 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 60661ce0fb77d5cbdc91436b4a2fc9182bfe2f81
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Mar 18 05:51:03 2015 +0100

    x2goclient.cpp: create new argv array on the heap instead of on the stack.
    
    Stack data will be invalid once the function goes out of scope (which is
    what execv is doing.)
---
 debian/changelog   |    3 +++
 src/x2goclient.cpp |   12 ++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6dba36b..1baf6d6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -73,6 +73,9 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
       after fork on virtually all operating system, especially on OS X.
     - x2goclient.cpp: fix compile problems introduced with the last commit.
     - x2goclient.cpp: fix string comparison.
+    - x2goclient.cpp: create new argv array on the heap instead of on the
+      stack. Stack data will be invalid once the function goes out of scope
+      (which is what execv is doing.)
   * debian/control:
     - Maintainer change in package: X2Go Developers <x2go-dev at lists.x2go.org>.
     - Uploaders: add myself. Also, force a rebuild due to the changed
diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp
index eee541f..c8df342 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -47,20 +47,20 @@ int fork_helper (int argc, char **argv) {
     new_argv.push_back (std::string (argv[0]));
     new_argv.push_back ("--unixhelper");
 
-    std::vector<char *> new_argv_c_str;
+    std::vector<char *> *new_argv_c_str = new (std::vector<char *>) ();
     for (std::vector<std::string>::iterator it = new_argv.begin (); it != new_argv.end (); ++it) {
       const char *elem = (*it).c_str ();
-      new_argv_c_str.push_back (strndup (elem, std::strlen (elem)));
+      new_argv_c_str->push_back (strndup (elem, std::strlen (elem)));
     }
 
     /* Add null pointer as last element. */
     {
-      std::vector<char> tmp;
-      tmp.push_back (0);
-      new_argv_c_str.push_back (&tmp.front ());
+      std::vector<char> *tmp = new (std::vector<char>) ();
+      tmp->push_back (0);
+      new_argv_c_str->push_back (&tmp->front ());
     }
 
-    if (0 != execv (new_argv_c_str.front (), &(new_argv_c_str.front ()))) {
+    if (0 != execv (new_argv_c_str->front (), &(new_argv_c_str->front ()))) {
       std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n"
                 << "Terminating and killing parent." << "\n"
                 << "Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl;

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list