|
public Boolean checkHeader() throws IOException { |
|
if (in.length() < 4) return null; |
|
|
|
// byte order must be II or MM |
|
in.seek(0); |
|
int endianOne = in.read(); |
|
int endianTwo = in.read(); |
|
boolean littleEndian = endianOne == TiffConstants.LITTLE && |
|
endianTwo == TiffConstants.LITTLE; // II |
|
boolean bigEndian = endianOne == TiffConstants.BIG && |
|
endianTwo == TiffConstants.BIG; // MM |
|
if (!littleEndian && !bigEndian) return null; |
|
|
|
// check magic number (42) |
|
in.order(littleEndian); |
|
short magic = in.readShort(); |
|
bigTiff = magic == TiffConstants.BIG_TIFF_MAGIC_NUMBER; |
|
if (magic != TiffConstants.MAGIC_NUMBER && |
|
magic != TiffConstants.BIG_TIFF_MAGIC_NUMBER) |
|
{ |
|
return null; |
|
} |
Referring to above, there are 3 places in method checkHeader() a null is returned. This will cause a Null Pointer Exception for those callers that are returned the result to a boolean data type and not the Boolean object.
Here are 2 examples of callers expecting boolean data type and not Boolean object:
|
littleEndian = parser.checkHeader(); |
|
in.order(tp.checkHeader().booleanValue()); |
Here’s an example of code checking for NULL and taking appropriate action:
|
Boolean littleEndian = tiffParser.checkHeader(); |
|
if (littleEndian == null) { |
|
throw new FormatException("Invalid TIFF file: " + id); |
|
} |
|
boolean little = littleEndian.booleanValue(); |
If it’s thought that this is an issue, my Eclipse seems to indicate there are about 10 other callers with this NPE situation.
bioformats/components/formats-bsd/src/loci/formats/tiff/TiffParser.java
Lines 199 to 220 in 678fd01
Referring to above, there are 3 places in method checkHeader() a null is returned. This will cause a Null Pointer Exception for those callers that are returned the result to a boolean data type and not the Boolean object.
Here are 2 examples of callers expecting boolean data type and not Boolean object:
bioformats/components/formats-bsd/src/loci/formats/out/PyramidOMETiffWriter.java
Line 129 in e4ffbe8
bioformats/components/formats-gpl/src/loci/formats/in/LeicaReader.java
Line 775 in 0a895ae
Here’s an example of code checking for NULL and taking appropriate action:
bioformats/components/formats-bsd/src/loci/formats/in/MinimalTiffReader.java
Lines 448 to 452 in 678fd01
If it’s thought that this is an issue, my Eclipse seems to indicate there are about 10 other callers with this NPE situation.