mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* process.c (rb_exec_fillarg): allocate one more element before
beginning in argv_str for try_with_sh. * internal.h (ARGVSTR2ARGC): adjust for the above change. (ARGVSTR2ARGV): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
41819dc447
commit
71fd73dff8
3 changed files with 17 additions and 7 deletions
|
@ -1,3 +1,11 @@
|
|||
Mon Jun 4 19:36:25 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* process.c (rb_exec_fillarg): allocate one more element before
|
||||
beginning in argv_str for try_with_sh.
|
||||
|
||||
* internal.h (ARGVSTR2ARGC): adjust for the above change.
|
||||
(ARGVSTR2ARGV): ditto.
|
||||
|
||||
Mon Jun 4 19:17:06 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* internal.h (ARGVSTR2ARGC): defined.
|
||||
|
|
|
@ -159,10 +159,12 @@ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
|
|||
|
||||
/* process.c */
|
||||
|
||||
/* argv_str contains an extra element for terminating NULL used by execve..
|
||||
/* argv_str contains extra two elements.
|
||||
* The beginning one is for /bin/sh used by exec_with_sh.
|
||||
* The last one for terminating NULL used by execve.
|
||||
* See rb_exec_fillarg() in process.c. */
|
||||
#define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 1)
|
||||
#define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str))
|
||||
#define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
|
||||
#define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
|
||||
|
||||
/* rational.c */
|
||||
VALUE rb_lcm(VALUE x, VALUE y);
|
||||
|
|
|
@ -1843,17 +1843,17 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, str
|
|||
}
|
||||
|
||||
if (e->argv_buf) {
|
||||
char *p, *ep;
|
||||
char *p, *ep, *null=NULL;
|
||||
VALUE argv_str;
|
||||
argv_str = hide_obj(rb_str_buf_new(sizeof(char*) * (argc + 1)));
|
||||
argv_str = hide_obj(rb_str_buf_new(sizeof(char*) * (argc + 2)));
|
||||
rb_str_buf_cat(argv_str, (char *)&null, sizeof(null)); /* place holder for /bin/sh of try_with_sh. */
|
||||
p = RSTRING_PTR(e->argv_buf);
|
||||
ep = p + RSTRING_LEN(e->argv_buf);
|
||||
while (p < ep) {
|
||||
rb_str_buf_cat(argv_str, (char *)&p, sizeof(p));
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
p = NULL;
|
||||
rb_str_buf_cat(argv_str, (char *)&p, sizeof(p));
|
||||
rb_str_buf_cat(argv_str, (char *)&null, sizeof(null)); /* terminator for execve. */
|
||||
e->argv_str = argv_str;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue