From 3683a5311724f55be3a2d4bb08dab7efe20baf7f Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 4 Sep 2006 07:26:47 +0000 Subject: * io.c (pipe_open): command name should not contain null bytes. [ruby-dev:29421] * process.c (proc_spawn): ditto. * process.c (proc_spawn_n): ditto. * process.c (rb_f_system): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'process.c') diff --git a/process.c b/process.c index a473fe991..3aaf68962 100644 --- a/process.c +++ b/process.c @@ -1136,13 +1136,13 @@ proc_spawn_n(argc, argv, prog) args = ALLOCA_N(char*, argc + 1); for (i = 0; i < argc; i++) { SafeStringValue(argv[i]); - args[i] = RSTRING(argv[i])->ptr; + args[i] = StringValueCStr(argv[i]); } if (prog) SafeStringValue(prog); args[i] = (char*) 0; if (args[0]) - return proc_spawn_v(args, prog ? RSTRING(prog)->ptr : 0); + return proc_spawn_v(args, prog ? StringValueCStr(prog) : 0); return -1; } @@ -1157,7 +1157,7 @@ proc_spawn(sv) int status; SafeStringValue(sv); - str = s = RSTRING(sv)->ptr; + str = s = StringValueCStr(sv); for (s = str; *s; s++) { if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) { char *shell = dln_find_exe("sh", 0); @@ -1458,7 +1458,7 @@ rb_f_system(argc, argv) if (argc == 1 && prog == 0) { #if defined(_WIN32) SafeStringValue(argv[0]); - status = do_spawn(P_WAIT, RSTRING(argv[0])->ptr); + status = do_spawn(P_WAIT, StringValueCStr(argv[0])); #else status = proc_spawn(argv[0]); #endif @@ -1486,7 +1486,7 @@ rb_f_system(argc, argv) cmd = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" ")); SafeStringValue(cmd); - status = system(RSTRING(cmd)->ptr); + status = system(StringValueCStr(cmd)); last_status_set((status & 0xff) << 8, 0); #else volatile VALUE prog = 0; @@ -1511,9 +1511,11 @@ rb_f_system(argc, argv) if (prog) { SafeStringValue(prog); + StringValueCStr(prog); } for (i = 0; i < argc; i++) { SafeStringValue(argv[i]); + StringValueCStr(argv[i]); } security(RSTRING(prog ? prog : argv[0])->ptr); chfunc = signal(SIGCHLD, SIG_DFL); -- cgit