ome / bioformats

Bio-Formats is a Java library for reading and writing data in life sciences image file formats. It is developed by the Open Microscopy Environment. Bio-Formats is released under the GNU General Public License (GPL); commercial licenses are available from Glencoe Software.
https://www.openmicroscopy.org/bio-formats
GNU General Public License v2.0
370 stars 241 forks source link

SDT: fix NegativeArraySizeException when reading files recorded by SPCM64 9.90 #4198

Open cqian89 opened 1 week ago

cqian89 commented 1 week ago

I encountered a java.lang.NegativeArraySizeException when reading files recorded by the latest version (9.90) of Becker Hickl's SPCM64 software. Files recorded with older versions don't seem to have this issue.

On further investigation, it seems to be related to a value setupLength. This should be an unsigned short, but was read as a signed short previously. In the SDT files recorded by the latest SPCM64, this seems to have exceeded the range of a signed short but is still within range of an unsigned short.

This PR fixes the error by changing readShort to readUnsignedShort and the type of setupLength to int.

Test data here: https://doi.org/10.5281/zenodo.12094862

melissalinkert commented 1 week ago

Thanks, @cqian89. This change makes sense to me, so it will be included in tonight's CI builds to see if any of our existing SDT test files are affected.

Before merging this pull request, we will need to have a signed Contributor License Agreement. Please submit the CLA according to the instructions here: https://ome-contributing.readthedocs.io/en/latest/cla.html

cqian89 commented 1 week ago

Thank you. I just submitted the signed CLA as per the instructions.