diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | builtin.c | 6 |
2 files changed, 9 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2011-10-27 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_strftime): Per Pat Rankin, instead of casting + fclock, use a long variable and check for negative or overflow. + 2011-10-25 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (dist-hook): Use `cd $(srcdir)/pc' so that @@ -1630,6 +1630,7 @@ do_strftime(int nargs) NODE *t1, *t2, *t3, *ret; struct tm *tm; time_t fclock; + long clock_val; char *bufp; size_t buflen, bufsize; char buf[BUFSIZ]; @@ -1676,9 +1677,10 @@ do_strftime(int nargs) t2 = POP_SCALAR(); if (do_lint && (t2->flags & (NUMCUR|NUMBER)) == 0) lintwarn(_("strftime: received non-numeric second argument")); - fclock = (time_t) force_number(t2); - if (((long int) fclock) < 0) + clock_val = (long) force_number(t2); + if (clock_val < 0) fatal(_("strftime: second argument less than 0 or too big for time_t")); + fclock = (time_t) clock_val; DEREF(t2); } |