From e6485d384879c0f3c6bf8f53ff7559bd5e437a76 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Mon, 7 Aug 2023 10:33:04 -0500 Subject: [PATCH] IVision: improve version and data type checks in isThisType Fixes #3582. --- .../formats-gpl/src/loci/formats/in/IvisionReader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/formats-gpl/src/loci/formats/in/IvisionReader.java b/components/formats-gpl/src/loci/formats/in/IvisionReader.java index 4de6677c9d6..22b758de9b5 100644 --- a/components/formats-gpl/src/loci/formats/in/IvisionReader.java +++ b/components/formats-gpl/src/loci/formats/in/IvisionReader.java @@ -94,7 +94,12 @@ public boolean isThisType(RandomAccessInputStream stream) throws IOException { String version = stream.readString(3); try { Double.parseDouble(version); - return version.indexOf('.') != -1 && version.indexOf('-') == -1; + boolean validVersion = version.indexOf('.') != -1 && version.indexOf('-') == -1; + boolean validPatch = Character.isAlphabetic(stream.read()); + stream.skipBytes(1); + int dataType = stream.read(); + boolean validType = dataType >= 0 && dataType <= 8; + return validVersion && validPatch && validType; } catch (NumberFormatException e) { } return false;