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

* process.c (proc_getpgrp): prohibit for $SAFE=2.

[ruby-dev:24899]

* process.c (get_pid): ditto.  [ruby-dev:24904]

* process.c (get_ppid): ditto.

* array.c (rb_ary_delete): defer rb_ary_modify() until actual
  modification.  [ruby-dev:24901]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-18 03:45:23 +00:00
parent 76fd9b85d9
commit b28b7933a8
4 changed files with 66 additions and 51 deletions

View file

@ -1,3 +1,15 @@
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (proc_getpgrp): prohibit for $SAFE=2.
[ruby-dev:24899]
* process.c (get_pid): ditto. [ruby-dev:24904]
* process.c (get_ppid): ditto.
* array.c (rb_ary_delete): defer rb_ary_modify() until actual
modification. [ruby-dev:24901]
Thu Nov 18 10:10:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c, rubyio.h (rb_io_modenum_flags): exported.
@ -9,20 +21,29 @@ Wed Nov 17 23:47:30 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
* test/ruby/test_settracefunc.rb: added. [ruby-dev:24884]
Wed Nov 17 11:48:17 2004 Michael Neumann <mneumann@ruby-lang.org>
* lib/xmlrpc/parser.rb, test/xmlrpc/test_features.rb: fixed "assinging
to constants" warnings
Wed Nov 17 18:59:16 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* process.c (proc_getrlimit, proc_setrlimit): add rb_secure(2) to
methods of Process.{getrlimit,setrlimit}
Wed Nov 17 13:56:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (newline_node): should not use FL_SET. [ruby-dev:24874]
* parse.y (string_content): should not use FL_UNSET.
* node.h (NODE_NEWLINE): remove unused bit to utilize flag field
in nodes.
Wed Nov 17 13:05:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (rb_push_glob): fix overrun. [ruby-dev:24886]
Wed Nov 17 11:48:17 2004 Michael Neumann <mneumann@ruby-lang.org>
* lib/xmlrpc/parser.rb, test/xmlrpc/test_features.rb: fixed "assinging
to constants" warnings
Wed Nov 17 09:38:18 2004 Johan Holmberg <holmberg@iar.se>
* re.c (rb_reg_initialize_m): should raise exception instead of

26
array.c
View file

@ -363,7 +363,6 @@ rb_ary_initialize(argc, argv, ary)
long len;
VALUE size, val;
rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
RARRAY(ary)->len = 0;
if (rb_block_given_p()) {
@ -387,6 +386,7 @@ rb_ary_initialize(argc, argv, ary)
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
rb_ary_modify(ary);
if (len > RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
RARRAY(ary)->aux.capa = len;
@ -445,7 +445,6 @@ rb_ary_store(ary, idx, val)
long idx;
VALUE val;
{
rb_ary_modify(ary);
if (idx < 0) {
idx += RARRAY(ary)->len;
if (idx < 0) {
@ -454,6 +453,7 @@ rb_ary_store(ary, idx, val)
}
}
rb_ary_modify(ary);
if (idx >= RARRAY(ary)->aux.capa) {
long new_capa = RARRAY(ary)->aux.capa / 2;
@ -1071,7 +1071,7 @@ rb_ary_to_ary(obj)
}
static void
rb_ary_update(ary, beg, len, rpl)
rb_ary_splice(ary, beg, len, rpl)
VALUE ary;
long beg, len;
VALUE rpl;
@ -1172,7 +1172,7 @@ rb_ary_aset(argc, argv, ary)
long offset, beg, len;
if (argc == 3) {
rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
rb_ary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
return argv[2];
}
if (argc != 2) {
@ -1184,7 +1184,7 @@ rb_ary_aset(argc, argv, ary)
}
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
rb_ary_update(ary, beg, len, argv[1]);
rb_ary_splice(ary, beg, len, argv[1]);
return argv[1];
}
@ -1226,7 +1226,7 @@ rb_ary_insert(argc, argv, ary)
}
if (argc == 1) return ary;
rb_ary_update(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
rb_ary_splice(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
return ary;
}
@ -1968,7 +1968,6 @@ rb_ary_delete(ary, item)
{
long i1, i2;
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
VALUE e = RARRAY(ary)->ptr[i1];
@ -1985,6 +1984,7 @@ rb_ary_delete(ary, item)
return Qnil;
}
rb_ary_modify(ary);
if (RARRAY(ary)->len > i2) {
RARRAY(ary)->len = i2;
if (i2 * 2 < RARRAY(ary)->aux.capa &&
@ -2005,13 +2005,13 @@ rb_ary_delete_at(ary, pos)
long i, len = RARRAY(ary)->len;
VALUE del;
rb_ary_modify(ary);
if (pos >= len) return Qnil;
if (pos < 0) {
pos += len;
if (pos < 0) return Qnil;
}
rb_ary_modify(ary);
del = RARRAY(ary)->ptr[pos];
for (i = pos + 1; i < len; i++, pos++) {
RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
@ -2076,7 +2076,6 @@ rb_ary_slice_bang(argc, argv, ary)
VALUE arg1, arg2;
long pos, len;
rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
pos = NUM2LONG(arg1);
len = NUM2LONG(arg2);
@ -2085,7 +2084,7 @@ rb_ary_slice_bang(argc, argv, ary)
pos = RARRAY(ary)->len + pos;
}
arg2 = rb_ary_subseq(ary, pos, len);
rb_ary_update(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */
rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */
return arg2;
}
@ -2457,7 +2456,7 @@ rb_ary_concat(x, y)
{
y = to_ary(y);
if (RARRAY(y)->len > 0) {
rb_ary_update(x, RARRAY(x)->len, 0, y);
rb_ary_splice(x, RARRAY(x)->len, 0, y);
}
return x;
}
@ -2873,8 +2872,6 @@ rb_ary_uniq_bang(ary)
VALUE hash, v, vv;
long i, j;
rb_ary_modify(ary);
hash = ary_make_hash(ary, 0);
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
@ -3005,7 +3002,7 @@ flatten(ary, idx, ary2, memo)
rb_raise(rb_eArgError, "tried to flatten recursive array");
}
rb_ary_push(memo, id);
rb_ary_update(ary, idx, 1, ary2);
rb_ary_splice(ary, idx, 1, ary2);
while (i < lim) {
VALUE tmp;
@ -3043,7 +3040,6 @@ rb_ary_flatten_bang(ary)
int mod = 0;
VALUE memo = Qnil;
rb_ary_modify(ary);
while (i<RARRAY(ary)->len) {
VALUE ary2 = RARRAY(ary)->ptr[i];
VALUE tmp;

View file

@ -6507,9 +6507,9 @@ static NODE*
newline_node(node)
NODE *node;
{
if (node) {
node->flags |= NODE_NEWLINE;
}
if (node) {
node->flags |= NODE_NEWLINE;
}
return node;
}

View file

@ -130,6 +130,7 @@ static VALUE S_Tms;
static VALUE
get_pid()
{
rb_secure(2);
return INT2FIX(getpid());
}
@ -153,6 +154,7 @@ get_pid()
static VALUE
get_ppid()
{
rb_secure(2);
#ifdef _WIN32
return INT2FIX(0);
#else
@ -730,6 +732,7 @@ proc_wait(argc, argv)
VALUE vpid, vflags;
int pid, flags, status;
rb_secure(2);
flags = 0;
rb_scan_args(argc, argv, "02", &vpid, &vflags);
if (argc == 0) {
@ -804,6 +807,7 @@ proc_waitall()
VALUE result;
int pid, status;
rb_secure(2);
result = rb_ary_new();
#ifdef NO_WAITPID
if (pid_tbl) {
@ -910,6 +914,7 @@ static VALUE
proc_detach(obj, pid)
VALUE pid;
{
rb_secure(2);
return rb_detach_process(NUM2INT(pid));
}
@ -1720,6 +1725,7 @@ proc_getpgrp()
{
int pgrp;
rb_secure(2);
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
pgrp = getpgrp();
if (pgrp < 0) rb_sys_fail(0);
@ -1747,12 +1753,13 @@ proc_getpgrp()
static VALUE
proc_setpgrp()
{
rb_secure(2);
/* check for posix setpgid() first; this matches the posix */
/* getpgrp() above. It appears that configure will set SETPGRP_VOID */
/* even though setpgrp(0,0) would be prefered. The posix call avoids */
/* this confusion. */
#ifdef HAVE_SETPGID
if (setpgid(0,0) < 0) rb_sys_fail(0);
if (setpgid(0,0) < 0) rb_sys_fail(0);
#elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID)
if (setpgrp() < 0) rb_sys_fail(0);
#else
@ -1777,8 +1784,10 @@ proc_getpgid(obj, pid)
VALUE obj, pid;
{
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
int i = getpgid(NUM2INT(pid));
int i;
rb_secure(2);
i = getpgid(NUM2INT(pid));
if (i < 0) rb_sys_fail(0);
return INT2NUM(i);
#else
@ -1886,6 +1895,7 @@ proc_getpriority(obj, which, who)
#ifdef HAVE_GETPRIORITY
int prio, iwhich, iwho;
rb_secure(2);
iwhich = NUM2INT(which);
iwho = NUM2INT(who);
@ -2545,6 +2555,7 @@ p_sys_issetugid(obj)
VALUE obj;
{
#if defined HAVE_ISSETUGID
rb_secure(2);
if (issetugid()) {
return Qtrue;
} else {
@ -3794,26 +3805,18 @@ Init_process()
rb_define_module_function(rb_mProcGID, "rid", proc_getgid, 0);
rb_define_module_function(rb_mProcUID, "eid", proc_geteuid, 0);
rb_define_module_function(rb_mProcGID, "eid", proc_getegid, 0);
rb_define_module_function(rb_mProcUID, "change_privilege",
p_uid_change_privilege, 1);
rb_define_module_function(rb_mProcGID, "change_privilege",
p_gid_change_privilege, 1);
rb_define_module_function(rb_mProcUID, "grant_privilege",
p_uid_grant_privilege, 1);
rb_define_module_function(rb_mProcGID, "grant_privilege",
p_gid_grant_privilege, 1);
rb_define_module_function(rb_mProcUID, "change_privilege", p_uid_change_privilege, 1);
rb_define_module_function(rb_mProcGID, "change_privilege", p_gid_change_privilege, 1);
rb_define_module_function(rb_mProcUID, "grant_privilege", p_uid_grant_privilege, 1);
rb_define_module_function(rb_mProcGID, "grant_privilege", p_gid_grant_privilege, 1);
rb_define_alias(rb_mProcUID, "eid=", "grant_privilege");
rb_define_alias(rb_mProcGID, "eid=", "grant_privilege");
rb_define_module_function(rb_mProcUID, "re_exchange", p_uid_exchange, 0);
rb_define_module_function(rb_mProcGID, "re_exchange", p_gid_exchange, 0);
rb_define_module_function(rb_mProcUID, "re_exchangeable?",
p_uid_exchangeable, 0);
rb_define_module_function(rb_mProcGID, "re_exchangeable?",
p_gid_exchangeable, 0);
rb_define_module_function(rb_mProcUID, "sid_available?",
p_uid_have_saved_id, 0);
rb_define_module_function(rb_mProcGID, "sid_available?",
p_gid_have_saved_id, 0);
rb_define_module_function(rb_mProcUID, "re_exchangeable?", p_uid_exchangeable, 0);
rb_define_module_function(rb_mProcGID, "re_exchangeable?", p_gid_exchangeable, 0);
rb_define_module_function(rb_mProcUID, "sid_available?", p_uid_have_saved_id, 0);
rb_define_module_function(rb_mProcGID, "sid_available?", p_gid_have_saved_id, 0);
rb_define_module_function(rb_mProcUID, "switch", p_uid_switch, 0);
rb_define_module_function(rb_mProcGID, "switch", p_gid_switch, 0);
@ -3833,15 +3836,10 @@ Init_process()
rb_define_module_function(rb_mProcID_Syscall, "seteuid", p_sys_seteuid, 1);
rb_define_module_function(rb_mProcID_Syscall, "setegid", p_sys_setegid, 1);
rb_define_module_function(rb_mProcID_Syscall, "setreuid",
p_sys_setreuid, 2);
rb_define_module_function(rb_mProcID_Syscall, "setregid",
p_sys_setregid, 2);
rb_define_module_function(rb_mProcID_Syscall, "setreuid", p_sys_setreuid, 2);
rb_define_module_function(rb_mProcID_Syscall, "setregid", p_sys_setregid, 2);
rb_define_module_function(rb_mProcID_Syscall, "setresuid",
p_sys_setresuid, 3);
rb_define_module_function(rb_mProcID_Syscall, "setresgid",
p_sys_setresgid, 3);
rb_define_module_function(rb_mProcID_Syscall, "issetugid",
p_sys_issetugid, 0);
rb_define_module_function(rb_mProcID_Syscall, "setresuid", p_sys_setresuid, 3);
rb_define_module_function(rb_mProcID_Syscall, "setresgid", p_sys_setresgid, 3);
rb_define_module_function(rb_mProcID_Syscall, "issetugid", p_sys_issetugid, 0);
}