summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2008-10-02 17:30:26 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-01-03 18:39:00 +0100
commit7315c673ba1f7464d13b316726d987b19ed41a4a (patch)
tree80aa3883193761c9c8c563e60620cbe23877f0d7 /pp_sys.c
parent806a119aef40085e6ee4a5a8bbab77cca98c9d08 (diff)
downloadperl-7315c673ba1f7464d13b316726d987b19ed41a4a.tar.gz
Fix pulling a large time off the stack by using a real double. What I really need is SvQV.
Fix list context with large years. List context can now go to 2**63-513. I don't know why that's not 2**63-1 but I'll take it. Maybe double imprecision. Scalar context with large years still busted. It appears to be something inside Perl_newSVpvf().
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 74958ac43f..5cfe38a844 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4402,6 +4402,7 @@ PP(pp_gmtime)
Time64_T when;
struct TM tmbuf;
struct TM *err;
+ char *opname = PL_op->op_type == OP_LOCALTIME ? "localtime" : "gmtime";
static const char * const dayname[] =
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
static const char * const monname[] =
@@ -4413,8 +4414,14 @@ PP(pp_gmtime)
(void)time(&now);
when = (Time64_T)now;
}
- else
- when = (Time64_T)SvNVx(POPs);
+ else {
+ double now = POPn;
+ when = (Time64_T)now;
+ if( when != now ) {
+ Perl_warner(aTHX_ packWARN(WARN_OVERFLOW),
+ "%.0f too large for %s", now, opname);
+ }
+ }
if (PL_op->op_type == OP_LOCALTIME)
err = localtime64_r(&when, &tmbuf);
@@ -4422,7 +4429,6 @@ PP(pp_gmtime)
err = gmtime64_r(&when, &tmbuf);
if( err == NULL ) {
- char *opname = PL_op->op_type == OP_LOCALTIME ? "localtime" : "gmtime";
Perl_warner(aTHX_ packWARN(WARN_OVERFLOW),
"%s under/overflowed the year", opname);
}
@@ -4455,7 +4461,7 @@ PP(pp_gmtime)
mPUSHi(tmbuf.tm_hour);
mPUSHi(tmbuf.tm_mday);
mPUSHi(tmbuf.tm_mon);
- mPUSHi(tmbuf.tm_year);
+ mPUSHn(tmbuf.tm_year);
mPUSHi(tmbuf.tm_wday);
mPUSHi(tmbuf.tm_yday);
mPUSHi(tmbuf.tm_isdst);