summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-07 03:20:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-07 03:20:53 +0000
commit3043170b14875ce53f3a951d665279b12c2c63a8 (patch)
tree5903ff25972c6d5399725ec7ad14fe25df9026f6 /time.c
parent1ec4d9d3e47132a4eeacc1a45a9e0bf1159ab3c8 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/time.c b/time.c
index 77257eb..32b3f0b 100644
--- a/time.c
+++ b/time.c
@@ -535,6 +535,15 @@ time_clone(time)
return clone;
}
+static void
+time_modify(time)
+ VALUE time;
+{
+ if (OBJ_FROZEN(time)) rb_error_frozen("Time");
+ if (!OBJ_TAINTED(time) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't modify Time");
+}
+
static VALUE
time_localtime(time)
VALUE time;
@@ -547,6 +556,7 @@ time_localtime(time)
if (tobj->tm_got && !tobj->gmt) {
return time;
}
+ time_modify(time);
t = tobj->tv.tv_sec;
tm_tmp = localtime(&t);
tobj->tm = *tm_tmp;
@@ -567,6 +577,7 @@ time_gmtime(time)
if (tobj->tm_got && tobj->gmt) {
return time;
}
+ time_modify(time);
t = tobj->tv.tv_sec;
tm_tmp = gmtime(&t);
tobj->tm = *tm_tmp;