From: Matthias Sohn Date: Tue, 20 Aug 2019 22:29:45 +0000 (+0200) Subject: Avoid sign extension when comparing mtime with Instant#getEpochSecond X-Git-Tag: v5.1.9.201908210455-r~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F148014%2F1;p=jgit.git Avoid sign extension when comparing mtime with Instant#getEpochSecond Ensure we use the same type when comparing seconds since the epoch. This does not prevent that in 2038 timestamps in seconds since the epoch stored in a 32 bit integer will overflow. Integer.MAX_VALUE translates to 2038-01-19T03:14:07Z. After this date we'll have an issue since we store seconds since the epoch in a 32 bit integer in some places. Bug: 319142 Change-Id: If0c03003d40b480f044686e2f7a2f62c9f4e2fe1 Signed-off-by: Matthias Sohn --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index d2a59c1310..b118fd6bc9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -378,7 +378,7 @@ public class DirCacheEntry { // final int base = infoOffset + P_MTIME; final int mtime = NB.decodeInt32(info, base); - if (smudge.getEpochSecond() == mtime) { + if ((int) smudge.getEpochSecond() == mtime) { return smudge.getNano() <= NB.decodeInt32(info, base + 4); } return false;