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

* ext/socket/socket.c (bsock_do_not_rev_lookup_set): should not be

allowed when $SAFE > 3.

* dir.c (fnmatch): "*/bar" (with FNM_PATHNAME flag) does not
  match "foo/bar".

* io.c (read_all): files on /proc filesystem with zero stat size,
  may have contents.

* eval.c (exec_under): changing ruby_class is OK, but should not
  alter cbase.

* eval.c (yield_under_i): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-03-25 06:16:02 +00:00
parent d68ea57b84
commit d645e92dd6
5 changed files with 44 additions and 45 deletions

View file

@ -1,3 +1,8 @@
Mon Mar 25 13:24:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (bsock_do_not_rev_lookup_set): should not be
allowed when $SAFE > 3.
Mon Mar 25 11:32:21 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* dln.c (dln_argv0): unused unless USE_DLN_A_OUT.
@ -6,6 +11,23 @@ Mon Mar 25 11:32:21 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/syslog: ditto.
Sun Mar 24 12:19:09 2002 Koji Arai <jca02266@nifty.ne.jp>
* dir.c (fnmatch): "*/bar" (with FNM_PATHNAME flag) does not
match "foo/bar".
Sat Mar 23 01:50:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (read_all): files on /proc filesystem with zero stat size,
may have contents.
Fri Mar 22 15:04:03 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (exec_under): changing ruby_class is OK, but should not
alter cbase.
* eval.c (yield_under_i): ditto.
Fri Mar 22 14:32:14 2002 Minero Aoki <aamine@loveruby.net>
* lib/net/protocol.rb: Protocol#start should return self.

4
dir.c
View file

@ -169,8 +169,10 @@ fnmatch(pat, string, flags)
}
else if (ISDIRSEP(c)) {
s = find_dirsep(s);
if (s)
if (s) {
s++;
break;
}
return FNM_NOMATCH;
}

50
eval.c
View file

@ -87,6 +87,10 @@ struct timeval {
#include <signal.h>
#include <errno.h>
#if defined(__VMS)
#pragma nostandard
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@ -2960,7 +2964,7 @@ rb_eval(self, n)
body = search_method(ruby_class, node->nd_mid, &origin);
if (body){
if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0) {
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
rb_warning("method redefined; discarding old %s", rb_id2name(node->nd_mid));
}
if (node->nd_noex) { /* toplevel */
/* should upgrade to rb_warn() if no super was called inside? */
@ -5022,9 +5026,9 @@ rb_f_eval(argc, argv, self)
/* function to call func under the specified class/module context */
static VALUE
exec_under(func, under, args)
exec_under(func, under, cbase, args)
VALUE (*func)();
VALUE under;
VALUE under, cbase;
void *args;
{
VALUE val; /* OK */
@ -5039,10 +5043,12 @@ exec_under(func, under, args)
ruby_frame->last_class = _frame.prev->last_class;
ruby_frame->argc = _frame.prev->argc;
ruby_frame->argv = _frame.prev->argv;
if (ruby_cbase != under) {
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,under,0,ruby_frame->cbase);
if (cbase) {
if (ruby_cbase != cbase) {
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,under,0,ruby_frame->cbase);
}
PUSH_CREF(cbase);
}
PUSH_CREF(under);
mode = scope_vmode;
SCOPE_SET(SCOPE_PUBLIC);
@ -5051,7 +5057,7 @@ exec_under(func, under, args)
val = (*func)(args);
}
POP_TAG();
POP_CREF();
if (cbase) POP_CREF();
SCOPE_SET(mode);
POP_FRAME();
POP_CLASS();
@ -5086,39 +5092,13 @@ eval_under(under, self, src, file, line)
args[1] = src;
args[2] = (VALUE)file;
args[3] = (VALUE)line;
return exec_under(eval_under_i, under, args);
return exec_under(eval_under_i, under, under, args);
}
static VALUE
yield_under_i(self)
VALUE self;
{
if (ruby_block->flags & BLOCK_DYNAMIC) {
struct BLOCK * volatile old_block = ruby_block;
struct BLOCK block;
/* cbase should be pointed from volatile local variable */
/* to be protected from GC. */
VALUE result;
int state;
block = *ruby_block;
/* copy the block to avoid modifying global data. */
block.frame.cbase = ruby_frame->cbase;
ruby_block = &block;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
result = rb_yield_0(self, self, ruby_class, 0);
}
POP_TAG();
ruby_block = old_block;
if (state) JUMP_TAG(state);
return result;
}
/* static block, no need to restore */
ruby_block->frame.cbase = ruby_frame->cbase;
return rb_yield_0(self, self, ruby_class, 0);
}
@ -5127,7 +5107,7 @@ static VALUE
yield_under(under, self)
VALUE under, self;
{
return exec_under(yield_under_i, under, self);
return exec_under(yield_under_i, under, 0, self);
}
static VALUE

View file

@ -499,6 +499,7 @@ bsock_do_not_rev_lookup()
static VALUE
bsock_do_not_rev_lookup_set(self, val)
{
rb_secure(4);
do_not_reverse_lookup = RTEST(val);
return val;
}

12
io.c
View file

@ -517,15 +517,9 @@ read_all(port)
#endif
)
{
if (st.st_size == 0) {
getc(fptr->f); /* force EOF */
return rb_str_new(0, 0);
}
else {
long pos = ftell(fptr->f);
if (st.st_size > pos && pos >= 0) {
siz = st.st_size - pos + 1;
}
long pos = ftell(fptr->f);
if (st.st_size > pos && pos >= 0) {
siz = st.st_size - pos + 1;
}
}
str = rb_tainted_str_new(0, siz);