summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
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 77257eb030..32b3f0b794 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;