diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-14 14:00:22 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-14 14:00:22 +0300 |
commit | 3de71423b3a39be0b9536413321c953cbf99b119 (patch) | |
tree | fcf3499b876b1677202d1013c229bbe5997ef03e /builtin.c | |
parent | f156eb53457a9e4e34c1b96f9e54eb130dffd8a3 (diff) | |
download | egawk-3de71423b3a39be0b9536413321c953cbf99b119.tar.gz egawk-3de71423b3a39be0b9536413321c953cbf99b119.tar.bz2 egawk-3de71423b3a39be0b9536413321c953cbf99b119.zip |
Improve negative time value checking for strftime.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -1913,17 +1913,13 @@ do_strftime(int nargs) lintwarn(_("strftime: received non-numeric second argument")); (void) force_number(t2); clock_val = get_number_si(t2); + fclock = (time_t) clock_val; /* - * 4/2015: This used to be here: - * - * if (clock_val < 0) - * fatal(_("strftime: second argument less than 0 or too big for time_t")); - * - * It is now disabled since some systems have strftime that works - * on times before the epoch. No arbritrary limits comes into - * play at this point. + * 4/2015: Protect against negative value being assigned + * to unsigned time_t. */ - fclock = (time_t) clock_val; + if (clock_val < 0 && fclock > 0) + fatal(_("strftime: second argument less than 0 or too big for time_t")); DEREF(t2); } |