diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-16 00:43:41 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-16 00:43:41 +0000 |
commit | d58d7f410587a48d0f8cad25658c2e0e652e2860 (patch) | |
tree | a00a020e6a893ea04012d566d6c72637c0b0d78d /dir.c | |
parent | 1b3beecb548cc2f28fdd4ecf92f3a976b84ad675 (diff) |
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -325,7 +325,17 @@ dir_closed() rb_raise(rb_eIOError, "closed directory"); } +static void +dir_check(dir) + VALUE dir; +{ + if (!OBJ_TAINTED(dir) && rb_safe_level() >= 4) + rb_raise(rb_eSecurityError, "Insecure: operation on untainted Dir"); + rb_check_frozen(dir); +} + #define GetDIR(obj, dirp) do {\ + dir_check(dir);\ Data_Get_Struct(obj, struct dir_data, dirp);\ if (dirp->dir == NULL) dir_closed();\ } while (0) @@ -536,6 +546,9 @@ dir_close(dir) { struct dir_data *dirp; + if (rb_safe_level() >= 4 && !OBJ_TAINTED(dir)) { + rb_raise(rb_eSecurityError, "Insecure: can't close"); + } GetDIR(dir, dirp); closedir(dirp->dir); dirp->dir = NULL; |