From: Rick Payne <ri...@rossfell.co.uk>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

Ensure that the argument to osv_system() is saved in allocated memory before we spawn the pthread

Signed-off-by: Rick Payne <ri...@rossfell.co.uk>
Message-Id: <1480355794-10065-1-git-send-email-ri...@rossfell.co.uk>

---
diff --git a/erlang/epmd.patch b/erlang/epmd.patch
--- a/erlang/epmd.patch
+++ b/erlang/epmd.patch
@@ -1,6 +1,5 @@
-diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
---- erts/etc/common/erlexec.c.orig     2015-06-24 02:56:21.000000000 +0800
-+++ erts/etc/common/erlexec.c  2015-09-05 20:25:57.297943048 +0800
+--- erts/etc/common/erlexec.c.orig     2016-03-14 16:11:15.000000000 -0400
++++ erts/etc/common/erlexec.c  2016-11-27 16:51:05.810884445 -0400
 @@ -31,6 +31,8 @@
  #include "erl_driver.h"
  #include <stdlib.h>
@@ -10,7 +9,7 @@ diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
  #include "erl_misc_utils.h"

  #ifdef __WIN32__
-@@ -398,6 +400,30 @@ add_extra_suffixes(char *prog, int type)
+@@ -399,6 +401,30 @@ add_extra_suffixes(char *prog, int type)
     return res;
  }

@@ -41,7 +40,7 @@ diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
  #ifdef __WIN32__
__declspec(dllexport) int win_erlexec(int argc, char **argv, HANDLE module, int windowed)
  #else
-@@ -1098,52 +1124,7 @@ int main(int argc, char **argv)
+@@ -1099,52 +1125,7 @@ int main(int argc, char **argv)
  #else

   skip_arg_massage:
@@ -95,7 +94,7 @@ diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
  #endif
  }

-@@ -1205,6 +1186,24 @@ usage_format(char *format, ...)
+@@ -1206,6 +1187,28 @@ usage_format(char *format, ...)
      usage_aux();
  }

@@ -112,15 +111,19 @@ diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
 +osv_system(char *command)
 +{
 +  pthread_t thread;
++  char *command_copy;
++
 +  if (!command)
 +    return 1;
-+  return pthread_create(&thread, NULL, osv_sh, command);
++
++  command_copy = strsave(command);
++  return pthread_create(&thread, NULL, osv_sh, command_copy);
 +}
 +
  void
  start_epmd(char *epmd)
  {
-@@ -1220,7 +1219,7 @@ start_epmd(char *epmd)
+@@ -1221,7 +1224,7 @@ start_epmd(char *epmd)
        erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "%s" DIRSEP "epmd", bindir);
        arg1 = "-daemon";
  #else
@@ -129,7 +132,7 @@ diff -up erts/etc/common/erlexec.c.orig erts/etc/common/erlexec.c
  #endif
      }
  #ifdef __WIN32__
-@@ -1244,9 +1243,9 @@ start_epmd(char *epmd)
+@@ -1245,9 +1248,9 @@ start_epmd(char *epmd)
            result = 0;
      }
  #else

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to