-
Notifications
You must be signed in to change notification settings - Fork 250
Open
Description
Regarding:
bioformats/components/formats-bsd/src/loci/formats/dicom/DicomTag.java
Lines 497 to 502 in 3679b52
| int n1 = DataTools.bytesToShort(b, 2, 2, in.isLittleEndian()); | |
| int n2 = DataTools.bytesToShort(b, 2, 2, !in.isLittleEndian()); | |
| n1 &= 0xffff; | |
| n2 &= 0xffff; | |
| if (n1 < 0 || n1 + in.getFilePointer() > in.length()) return n2; | |
| if (n2 < 0 || n2 + in.getFilePointer() > in.length()) return n1; |
I don’t think the check for negative is ever checked for correctly.
Variables n1 and n2 are ints but populated by shorts. Thus, if the shorts are negative they will be sign extended to negative for ints n1 and n2.
Via the code “&= 0xffff;”, the most significant 16 bits of the ints n1 and n2 are set to 0, thus losing the negativity of the number.
Thus, the checks for negativity (n1< 0 and n2<0) are never true.
Should n1 and n2 be changed to short and the two “&=” statement be removed?
short n1 = DataTools.bytesToShort(b, 2, 2, in.isLittleEndian());
short n2 = DataTools.bytesToShort(b, 2, 2, !in.isLittleEndian());
if (n1 < 0 || n1 + in.getFilePointer() > in.length()) return n2;
if (n2 < 0 || n2 + in.getFilePointer() > in.length()) return n1;
Metadata
Metadata
Assignees
Labels
No labels