From 750924c556fbb0c431e983ec57befb9a7f070685 Mon Sep 17 00:00:00 2001 From: Marian Koncek Date: Fri, 3 Jun 2022 12:43:45 +0200 Subject: [PATCH] Fix integer overflow when parsing SOURCE_DATE_EPOCH Upstream: https://github.com/apache/ant/pull/186/commits --- .../org/apache/tools/ant/taskdefs/Tstamp.java | 2 +- src/tests/antunit/taskdefs/tstamp-test.xml | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java index aa1034e..ca10efe 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java @@ -82,7 +82,7 @@ public class Tstamp extends Task { try { if (epoch != null) { // Value of SOURCE_DATE_EPOCH will be an integer, representing seconds. - d = new Date(Integer.parseInt(epoch) * 1000); + d = new Date(Long.parseLong(epoch) * 1000L); log("Honouring environment variable " + ENV_SOURCE_DATE_EPOCH + " which has been set to " + epoch); } } catch(NumberFormatException e) { diff --git a/src/tests/antunit/taskdefs/tstamp-test.xml b/src/tests/antunit/taskdefs/tstamp-test.xml index 20c3227..1553d32 100644 --- a/src/tests/antunit/taskdefs/tstamp-test.xml +++ b/src/tests/antunit/taskdefs/tstamp-test.xml @@ -75,4 +75,35 @@ public class IsEpochIn1969Here implements Condition { + + + + + + + + + + + + + + + + -- 2.35.1