From 9b73ec4d12d65f3366e7cc5c3533d84d8c442a67 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 9 Aug 2024 11:53:01 +0200 Subject: Fix "Comparison of narrow type with wide type in loop condition" This issue was detected by a GitHub CodeQL security scan run on JGit source code. Description of the error raised by the security scan: "In a loop condition, comparison of a value of a narrow type with a value of a wide type may always evaluate to true if the wider value is sufficiently large (or small). This is because the narrower value may overflow. This can lead to an infinite loop." Fix this by using type `long` for the local variable `done`. Change-Id: Ibd4f71299e3f2e40d4331227bd143569a4264d8c --- org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'org.eclipse.jgit/src/org/eclipse') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java index 715cbb48fb..cfceed00e8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java @@ -531,7 +531,7 @@ public abstract class PackParser { receiving.beginTask(JGitText.get().receivingObjects, (int) expectedObjectCount); try { - for (int done = 0; done < expectedObjectCount; done++) { + for (long done = 0; done < expectedObjectCount; done++) { indexOneObject(); receiving.update(1); if (receiving.isCancelled()) -- cgit v1.2.3