Skip to content

Commit

Permalink
* io.c (rb_io_initialize): should check rb_secure(4).
Browse files Browse the repository at this point in the history
* dir.c (dir_s_getwd): should check rb_secure(4).

* object.c (rb_obj_infect): function version of OBJ_INFECT().

* eval.c (rb_secure_update): new function to check object update.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 25, 2003
1 parent 2d505ae commit d4db9e9
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Tue Mar 25 12:01:54 2003 Yukihiro Matsumoto <[email protected]>

* io.c (rb_io_initialize): should check rb_secure(4).

* dir.c (dir_s_getwd): should check rb_secure(4).

* object.c (rb_obj_infect): function version of OBJ_INFECT().

* eval.c (rb_secure_update): new function to check object update.

Tue Mar 25 10:18:05 2003 Minero Aoki <[email protected]>

* ext/strscan/strscan.c: should infect also return values of
Expand Down
8 changes: 6 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,12 @@ static VALUE
dir_s_getwd(dir)
VALUE dir;
{
char *path = my_getcwd();
VALUE cwd = rb_tainted_str_new2(path);
char *path;
VALUE cwd;

rb_secure(4);
path = my_getcwd();
cwd = rb_tainted_str_new2(path);

free(path);
return cwd;
Expand Down
7 changes: 7 additions & 0 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ rb_secure(level)
}
}

void
rb_secure_update(obj)
VALUE obj;
{
if (!OBJ_TAINTED(obj)) rb_secure(4);
}

void
rb_check_safe_obj(x)
VALUE x;
Expand Down
1 change: 1 addition & 0 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,7 @@ rb_io_initialize(argc, argv, io)
int fd, flags;
char mbuf[4];

rb_secure(4);
rb_scan_args(argc, argv, "11", &fnum, &mode);
fd = NUM2INT(fnum);
if (argc == 2) {
Expand Down
7 changes: 7 additions & 0 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ rb_obj_untaint(obj)
return obj;
}

void
rb_obj_infect(obj1, obj2)
VALUE obj1, obj2;
{
OBJ_INFECT(obj1, obj2);
}

VALUE
rb_obj_freeze(obj)
VALUE obj;
Expand Down
3 changes: 3 additions & 0 deletions ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ void rb_secure _((int));
RUBY_EXTERN int ruby_safe_level;
#define rb_safe_level() (ruby_safe_level)
void rb_set_safe_level _((int));
void rb_secure_update _((VALUE));

long rb_num2long _((VALUE));
unsigned long rb_num2ulong _((VALUE));
Expand Down Expand Up @@ -457,6 +458,8 @@ struct RBignum {
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))

void rb_obj_infect _((VALUE,VALUE));

void rb_glob _((char*,void(*)(const char*,VALUE),VALUE));
void rb_globi _((char*,void(*)(const char*,VALUE),VALUE));

Expand Down

0 comments on commit d4db9e9

Please sign in to comment.