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

* lib/irb.rb (IRB::Irb::eval_input): warn and exit if $SAFE >=3

after input evaluation.

* lib/irb.rb (IRB::Irb::eval_input): untaint input string.  now
  irb works for levels 1 and 2.

* ext/syck/rubyext.c (syck_loader_transfer): should not use
  rb_cProc directly, since type_proc may be Proc, Block, or
  Method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-06-10 05:22:17 +00:00
parent 434e71244a
commit 373a59b95b
6 changed files with 30 additions and 11 deletions

View file

@ -1,3 +1,11 @@
Tue Jun 10 01:07:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/irb.rb (IRB::Irb::eval_input): warn and exit if $SAFE >=3
after input evaluation.
* lib/irb.rb (IRB::Irb::eval_input): untaint input string. now
irb works for levels 1 and 2.
Mon Jun 9 19:02:33 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net> Mon Jun 9 19:02:33 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* configure.in: checks presence of grp.h and setgroups(). * configure.in: checks presence of grp.h and setgroups().
@ -13,6 +21,10 @@ Sun Jun 8 13:37:21 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
Sat Jun 7 22:22:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Sat Jun 7 22:22:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/rubyext.c (syck_loader_transfer): should not use
rb_cProc directly, since type_proc may be Proc, Block, or
Method.
* parse.y (value_expr0): class and module statements should not be * parse.y (value_expr0): class and module statements should not be
warned for "void value expression". [ruby-talk:72989] warned for "void value expression". [ruby-talk:72989]

View file

@ -773,7 +773,7 @@ syck_loader_transfer( self, type, val )
// rb_funcall(rb_mKernel, rb_intern("p"), 2, name, type_proc); // rb_funcall(rb_mKernel, rb_intern("p"), 2, name, type_proc);
} }
if ( rb_obj_is_instance_of( type_proc, rb_cProc ) ) if ( rb_respond_to( type_proc, rb_intern("call") ) )
{ {
val = rb_funcall(type_proc, rb_intern("call"), 2, type_uri, val); val = rb_funcall(type_proc, rb_intern("call"), 2, type_uri, val);
} }

View file

@ -141,10 +141,10 @@ module IRB
end end
end end
@scanner.each_top_level_statement do @scanner.each_top_level_statement do |line, line_no|
|line, line_no|
signal_status(:IN_EVAL) do signal_status(:IN_EVAL) do
begin begin
line.untaint
@context.evaluate(line, line_no) @context.evaluate(line, line_no)
output_value if @context.echo? output_value if @context.echo?
rescue StandardError, ScriptError, Abort rescue StandardError, ScriptError, Abort
@ -180,6 +180,10 @@ module IRB
end end
print "Maybe IRB bug!!\n" if irb_bug print "Maybe IRB bug!!\n" if irb_bug
end end
if $SAFE > 2
warn "Error: irb does not work for $SAFE level higher than 2"
exit 1
end
end end
end end
end end

View file

@ -69,12 +69,12 @@ class RubyLex
# io functions # io functions
def set_input(io, p = nil) def set_input(io, p = nil)
@io = io @io = io
if p.kind_of?(Proc) if p.respond_to?(:call)
@input = p @input = p
elsif iterator? elsif iterator?
@input = proc @input = Block.new
else else
@input = proc{@io.gets} @input = Block.new{@io.gets}
end end
end end
@ -183,11 +183,11 @@ class RubyLex
end end
private :buf_input private :buf_input
def set_prompt(p = proc) def set_prompt(p = Block.new)
if p.kind_of?(Proc) if p.respond_to?(:call)
@prompt = p @prompt = p
else else
@prompt = proc{print p} @prompt = Block.new{print p}
end end
end end

View file

@ -33,13 +33,13 @@ class SLex
def def_rule(token, preproc = nil, postproc = nil) def def_rule(token, preproc = nil, postproc = nil)
# print node.inspect, "\n" if SLex.debug? # print node.inspect, "\n" if SLex.debug?
postproc = proc if iterator? postproc = Block.new if iterator?
node = create(token, preproc, postproc) node = create(token, preproc, postproc)
end end
def def_rules(*tokens) def def_rules(*tokens)
if iterator? if iterator?
p = proc p = Block.new
end end
for token in tokens for token in tokens
def_rule(token, nil, p) def_rule(token, nil, p)

View file

@ -1283,6 +1283,9 @@ proc_setgroups(VALUE obj, VALUE ary)
} }
else { else {
gr = getgrnam(RSTRING(g)->ptr); gr = getgrnam(RSTRING(g)->ptr);
if (gr == NULL)
rb_raise(rb_eArgError, "can't find group for %s", RSTRING(g)->ptr);
groups[i] = gr->gr_gid;
} }
} }
} }