aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-14 14:17:26 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-14 14:17:26 +0300
commit82ef375e5236341b6550c1c365ec87bd23c049bf (patch)
tree6bff0b64da3a688246daf5af035629160f756fc0
parentc94c41be952af8be29166fca886bbb11b3fe3330 (diff)
parentd3d01be8a74e50ec3cb58ba9acd99f08ade5a606 (diff)
downloadegawk-82ef375e5236341b6550c1c365ec87bd23c049bf.tar.gz
egawk-82ef375e5236341b6550c1c365ec87bd23c049bf.tar.bz2
egawk-82ef375e5236341b6550c1c365ec87bd23c049bf.zip
Merge branch 'master' into feature/regex-type
-rw-r--r--ChangeLog14
-rw-r--r--builtin.c8
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am10
-rw-r--r--test/Makefile.in9
-rw-r--r--test/negtime.awk4
-rw-r--r--test/negtime.ok1
7 files changed, 47 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 69e59ef8..af5114af 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).
@@ -7,6 +14,13 @@
* regexec.c (buid_trtable, match_ctx_clean): Replace malloc/free
with re_malloc/re_free.
+ Unrelated:
+
+ * builtin.c (do_strftime): Disable checking timestamp value for less
+ than zero. Allows times before the epoch to work with strftime.
+ Thanks to Glaudiston Gomes da Silva <glaudistong@gmail.com>
+ for raising the issue.
+
2015-04-12 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (efence): Make this link again.
diff --git a/builtin.c b/builtin.c
index 2ebdaded..1f59d3f6 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1921,9 +1921,13 @@ do_strftime(int nargs)
lintwarn(_("strftime: received non-numeric second argument"));
(void) force_number(t2);
clock_val = get_number_si(t2);
- if (clock_val < 0)
- fatal(_("strftime: second argument less than 0 or too big for time_t"));
fclock = (time_t) clock_val;
+ /*
+ * 4/2015: Protect against negative value being assigned
+ * to unsigned time_t.
+ */
+ if (clock_val < 0 && fclock > 0)
+ fatal(_("strftime: second argument less than 0 or too big for time_t"));
DEREF(t2);
}
diff --git a/test/ChangeLog b/test/ChangeLog
index e7f181f1..4d397134 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (negtime): New test.
+ * negtime.awk, negtime.ok: New files.
+
2015-04-09 Arnold D. Robbins <arnold@skeeve.com>
* fts.awk: Skip atime to avoid spurious timestamp
diff --git a/test/Makefile.am b/test/Makefile.am
index d7e96353..9ec3fc6c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -574,6 +574,8 @@ EXTRA_DIST = \
negexp.ok \
negrange.awk \
negrange.ok \
+ negtime.awk \
+ negtime.ok \
nested.awk \
nested.in \
nested.ok \
@@ -1067,7 +1069,7 @@ GAWK_EXT_TESTS = \
include include2 indirectbuiltin indirectcall indirectcall2 \
lint lintold lintwarn \
manyfiles match1 match2 match3 mbstr1 \
- nastyparm next nondec nondec2 \
+ nastyparm negtime next nondec nondec2 \
nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
profile0 profile1 profile2 profile3 profile4 profile5 profile6 profile7 \
@@ -2095,6 +2097,12 @@ paramasfunc2::
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+negtime::
+ @echo $@
+ @TZ=GMT AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+
# Targets generated for other tests:
include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index 5c7314f1..ea0a4a27 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -831,6 +831,8 @@ EXTRA_DIST = \
negexp.ok \
negrange.awk \
negrange.ok \
+ negtime.awk \
+ negtime.ok \
nested.awk \
nested.in \
nested.ok \
@@ -1323,7 +1325,7 @@ GAWK_EXT_TESTS = \
include include2 indirectbuiltin indirectcall indirectcall2 \
lint lintold lintwarn \
manyfiles match1 match2 match3 mbstr1 \
- nastyparm next nondec nondec2 \
+ nastyparm negtime next nondec nondec2 \
nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
profile0 profile1 profile2 profile3 profile4 profile5 profile6 profile7 \
@@ -2530,6 +2532,11 @@ paramasfunc2::
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+negtime::
+ @echo $@
+ @TZ=GMT AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
diff --git a/test/negtime.awk b/test/negtime.awk
new file mode 100644
index 00000000..743c6d05
--- /dev/null
+++ b/test/negtime.awk
@@ -0,0 +1,4 @@
+BEGIN {
+then = mktime("1959 12 15 7 00 00")
+print strftime(PROCINFO["strftime"], then)
+}
diff --git a/test/negtime.ok b/test/negtime.ok
new file mode 100644
index 00000000..aa2ae694
--- /dev/null
+++ b/test/negtime.ok
@@ -0,0 +1 @@
+Tue Dec 15 07:00:00 GMT 1959