From cc0be003a42d4b2d0d7d4dd11c87dce6bb567dca Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Wed, 8 Jul 2026 15:40:44 +0300 Subject: [PATCH] Widen volumeHandle to long before shifting by 48 (CodeQL java/lshift-larger-than-type-width) In IOMeter.dump() the composite event key was built as "(volumeHandle << 48) + pageAddress". volumeHandle is an int, and Java uses only the low 5 bits of an int shift distance, so "<< 48" was silently evaluated as "<< 16" in 32-bit arithmetic before being widened to long. The handle therefore placed volumeHandle in the wrong bit range (and could overflow int), so events for different volumes/pages could collide on the same HashMap key when dumping with analyzePages. Cast volumeHandle to long first so the shift is performed in 64 bits: ((long) volumeHandle << 48) + pageAddress. This only affects the -a page analysis of the journal dump utility. --- persistit/core/src/main/java/com/persistit/IOMeter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistit/core/src/main/java/com/persistit/IOMeter.java b/persistit/core/src/main/java/com/persistit/IOMeter.java index 6773ab7fd..65d2a79ba 100644 --- a/persistit/core/src/main/java/com/persistit/IOMeter.java +++ b/persistit/core/src/main/java/com/persistit/IOMeter.java @@ -280,7 +280,7 @@ private void dump(final DataInputStream is, final int count, final boolean analy if (analyzePages && (op == WRITE_PAGE_TO_JOURNAL || op == READ_PAGE_FROM_JOURNAL || op == READ_PAGE_FROM_VOLUME || op == COPY_PAGE_FROM_JOURNAL || op == COPY_PAGE_TO_VOLUME || op == EVICT_PAGE_FROM_POOL)) { - final long handle = (volumeHandle << 48) + pageAddress; + final long handle = ((long) volumeHandle << 48) + pageAddress; List list = events.get(handle); if (list == null) { list = new ArrayList(2);