docs: private static int readTiffHeader(InputStream is, int length, TiffHeader tiffHeader)
        throws IOException {
      if (length <= 8) {
        return 0;
      }
  
      // read the byte order
      tiffHeader.byteOrder = StreamProcessor.readPackedInt(is, 4, false);
      length -= 4;
      if (tiffHeader.byteOrder != TIFF_BYTE_ORDER_LITTLE_END &&
          tiffHeader.byteOrder != TIFF_BYTE_ORDER_BIG_END) {
        FLog.e(TAG, "Invalid TIFF header");
        return 0;
      }
      tiffHeader.isLittleEndian = (tiffHeader.byteOrder == TIFF_BYTE_ORDER_LITTLE_END);
  
      // read the offset of the first IFD and check if it is reasonable
      tiffHeader.firstIfdOffset = StreamProcessor.readPackedInt(is, 4, tiffHeader.isLittleEndian);
      length -= 4;
      if (tiffHeader.firstIfdOffset < 8 || tiffHeader.firstIfdOffset - 8 > length) {
        FLog.e(TAG, "Invalid offset");
        return 0;
      }
  
      return length;
    }