summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-28 08:43:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-28 08:43:25 +0000
commit62261ccb47fce9c4728cfbeb84f81d23369ab910 (patch)
tree3f1464728d4c6d3ba1e64bbe22e1f00672a8690a /process.c
parent6771ffa97125d57a48378daed460ec22db7dd835 (diff)
* object.c (rb_str2cstr): warn if string contains \0 and length
value is ignored. * class.c (rb_singleton_class_clone): should copy class constant table as well. * class.c (rb_include_module): sometimes cache was mistakenly left uncleared - based on the patch by K.Kosako. * ruby.h: all Check_SafeStr()'s are replaced by SafeStr() to ensure 'to_str' be always effective. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/process.c b/process.c
index 7f62331..101a4d0 100644
--- a/process.c
+++ b/process.c
@@ -564,6 +564,7 @@ proc_exec_n(argc, argv, progv)
}
args = ALLOCA_N(char*, argc+1);
for (i=0; i<argc; i++) {
+ SafeStr(argv[i]);
args[i] = RSTRING(argv[i])->ptr;
}
args[i] = 0;
@@ -690,10 +691,10 @@ proc_spawn_n(argc, argv, prog)
args = ALLOCA_N(char*, argc + 1);
for (i = 0; i < argc; i++) {
- Check_SafeStr(argv[i]);
+ SafeStr(argv[i]);
args[i] = RSTRING(argv[i])->ptr;
}
- Check_SafeStr(prog);
+ SafeStr(prog);
args[i] = (char*) 0;
if (args[0])
return proc_spawn_v(args, RSTRING(prog)->ptr);
@@ -709,7 +710,7 @@ proc_spawn(sv)
char **argv, **a;
int status;
- Check_SafeStr(sv);
+ SafeStr(sv);
str = s = RSTRING(sv)->ptr;
for (s = str; *s; s++) {
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
@@ -752,13 +753,13 @@ rb_f_exec(argc, argv)
argv[0] = RARRAY(argv[0])->ptr[1];
}
if (prog) {
- Check_SafeStr(prog);
- }
- for (i = 0; i < argc; i++) {
- Check_SafeStr(argv[i]);
+ SafeStr(prog);
}
if (argc == 1 && prog == 0) {
- rb_proc_exec(RSTRING(argv[0])->ptr);
+ VALUE cmd = argv[0];
+
+ SafeStr(cmd);
+ rb_proc_exec(RSTRING(cmd)->ptr);
}
else {
proc_exec_n(argc, argv, prog);
@@ -875,7 +876,7 @@ rb_f_system(argc, argv)
}
cmd = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- Check_SafeStr(cmd);
+ SafeStr(cmd);
status = do_spawn(RSTRING(cmd)->ptr);
last_status_set(status);
@@ -899,7 +900,7 @@ rb_f_system(argc, argv)
}
cmd = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- Check_SafeStr(cmd);
+ SafeStr(cmd);
status = system(RSTRING(cmd)->ptr);
last_status_set((status & 0xff) << 8);
@@ -956,10 +957,10 @@ rb_f_system(argc, argv)
}
if (prog) {
- Check_SafeStr(prog);
+ SafeStr(prog);
}
for (i = 0; i < argc; i++) {
- Check_SafeStr(argv[i]);
+ SafeStr(argv[i]);
}
retry:
switch (pid = vfork()) {