aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-14 14:15:29 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-14 14:15:29 +0300
commitd3d01be8a74e50ec3cb58ba9acd99f08ade5a606 (patch)
treed7eaa1da59f05059c2b0c431cc829e062e7cf805
parent11692d41b177e93df106309cf2eda493350bee35 (diff)
parent3de71423b3a39be0b9536413321c953cbf99b119 (diff)
downloadegawk-d3d01be8a74e50ec3cb58ba9acd99f08ade5a606.tar.gz
egawk-d3d01be8a74e50ec3cb58ba9acd99f08ade5a606.tar.bz2
egawk-d3d01be8a74e50ec3cb58ba9acd99f08ade5a606.zip
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog7
-rw-r--r--builtin.c14
2 files changed, 12 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 1832a9e4..8cf0c532 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * builtin.c (do_strftime): Restore checking for negative result and
+ add check that time_t is > 0 --- means we're assigning a negative value
+ to an unsigned time_t. Thanks again to Glaudiston Gomes da Silva
+ <glaudistong@gmail.com>.
+
2015-04-13 Arnold D. Robbins <arnold@skeeve.com>
* regcomp.c (analyze): Prevent malloc(0).
diff --git a/builtin.c b/builtin.c
index 6658e750..57669170 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1921,17 +1921,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);
}