aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-16 18:02:29 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-16 18:02:29 +0300
commit6f250fa2a01864e07c1e9022f36eab740a2793c5 (patch)
treee77711678bef18e003b614f3c7e3e6c222bb23b4 /builtin.c
parent340c6b9945fcf57666648939bb8702a6f64c8e8e (diff)
parentaaa85643b352f867cfe7198f313b4481ad1f544d (diff)
downloadegawk-6f250fa2a01864e07c1e9022f36eab740a2793c5.tar.gz
egawk-6f250fa2a01864e07c1e9022f36eab740a2793c5.tar.bz2
egawk-6f250fa2a01864e07c1e9022f36eab740a2793c5.zip
Merge branch 'master' into feature/regex-type
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/builtin.c b/builtin.c
index e8a9614f..d50e75ae 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1872,7 +1872,7 @@ do_strftime(int nargs)
NODE *t1, *t2, *t3, *ret;
struct tm *tm;
time_t fclock;
- long clock_val;
+ double clock_val;
char *bufp;
size_t buflen, bufsize;
char buf[BUFSIZ];
@@ -1881,6 +1881,8 @@ do_strftime(int nargs)
int do_gmt;
NODE *val = NULL;
NODE *sub = NULL;
+ static const time_t time_t_min = TYPE_MINIMUM(time_t);
+ static const time_t time_t_max = TYPE_MAXIMUM(time_t);
/* set defaults first */
format = def_strftime_format; /* traditional date format */
@@ -1920,7 +1922,7 @@ do_strftime(int nargs)
if (do_lint && (t2->flags & (NUMCUR|NUMBER)) == 0)
lintwarn(_("strftime: received non-numeric second argument"));
(void) force_number(t2);
- clock_val = get_number_si(t2);
+ clock_val = get_number_d(t2);
fclock = (time_t) clock_val;
/*
* 4/2015: Protect against negative value being assigned
@@ -1928,6 +1930,11 @@ do_strftime(int nargs)
*/
if (clock_val < 0 && fclock > 0)
fatal(_("strftime: second argument less than 0 or too big for time_t"));
+
+ /* And check that the value is in range */
+ if (clock_val < time_t_min || clock_val > time_t_max)
+ fatal(_("strftime: second argument out of range for time_t"));
+
DEREF(t2);
}