From 15c8d8bbd710adf11b21dfe3e33c7bdbc6589369 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Tue, 15 Aug 2023 16:31:56 -0500 Subject: [PATCH 1/2] NDPI: correct for potential integer overflow in stored restart marker tag Fixes #4082. --- .../formats-gpl/src/loci/formats/in/NDPIReader.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/formats-gpl/src/loci/formats/in/NDPIReader.java b/components/formats-gpl/src/loci/formats/in/NDPIReader.java index c2db3029207..c0704d207f7 100644 --- a/components/formats-gpl/src/loci/formats/in/NDPIReader.java +++ b/components/formats-gpl/src/loci/formats/in/NDPIReader.java @@ -202,6 +202,14 @@ else if (useTiffParser(ifds.get(ifdIndex))) { markers[i] = markers[i] & 0xffffffffL; } } + else { + // might need to correct offset overflow by adding 4GB to offsets + for (int i=1; i Date: Mon, 25 Sep 2023 16:45:00 -0500 Subject: [PATCH 2/2] NDPI: check for tag 65432, representing the upper 32 bits of the marker offsets --- .../src/loci/formats/in/NDPIReader.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/formats-gpl/src/loci/formats/in/NDPIReader.java b/components/formats-gpl/src/loci/formats/in/NDPIReader.java index c0704d207f7..6da4236d697 100644 --- a/components/formats-gpl/src/loci/formats/in/NDPIReader.java +++ b/components/formats-gpl/src/loci/formats/in/NDPIReader.java @@ -71,6 +71,7 @@ public class NDPIReader extends BaseTiffReader { private static final int TISSUE_INDEX = 65425; private static final int MARKER_TAG = 65426; private static final int REFERENCE = 65427; + private static final int MARKER_TAG_HIGH_BYTES = 65432; private static final int FILTER_SET_NAME = 65434; private static final int EXPOSURE_RATIO = 65435; private static final int RED_MULTIPLIER = 65436; @@ -197,13 +198,28 @@ else if (useTiffParser(ifds.get(ifdIndex))) { try { service.close(); long[] markers = ifd.getIFDLongArray(MARKER_TAG); + long[] markerHighBytes = ifd.getIFDLongArray(MARKER_TAG_HIGH_BYTES); if (!use64Bit) { for (int i=0; i