1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ruby.c (set_arg0): fix breaking environ bugs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-11-09 01:10:06 +00:00
parent 9099eab331
commit 0303c1d42b
2 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Fri Nov 9 10:05:54 2007 Koichi Sasada <ko1@atdot.net>
* ruby.c (set_arg0): fix breaking environ bugs.
Fri Nov 9 07:26:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Nov 9 07:26:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* random.c: update MT URL.[ruby-core:13305]. * random.c: update MT URL.[ruby-core:13305].

15
ruby.c
View file

@ -1173,7 +1173,7 @@ get_arglen(int argc, char **argv)
static void static void
set_arg0(VALUE val, ID id) set_arg0(VALUE val, ID id)
{ {
char *s; char *s, *t;
long i; long i;
if (origarg.argv == 0) if (origarg.argv == 0)
@ -1204,13 +1204,16 @@ set_arg0(VALUE val, ID id)
} }
memcpy(origarg.argv[0], s, i); memcpy(origarg.argv[0], s, i);
s = origarg.argv[0] + i; t = origarg.argv[0] + i;
*s = '\0'; *t = '\0';
if (i + 1 < origarg.len) memset(s + 1, ' ', origarg.len - i - 1);
if (i + 1 < origarg.len) memset(t + 1, ' ', origarg.len - i - 1);
{ {
int j; int j;
for (j = 1; j < origarg.argc; j++) for (j = 1; j < origarg.argc; j++) {
origarg.argv[i] = s; origarg.argv[j] = t;
}
} }
#endif #endif
rb_progname = rb_tainted_str_new(s, i); rb_progname = rb_tainted_str_new(s, i);