Program: 92922
Project: 92922
Buggy source:
private void processMakerNote(int subdirOffset,@NotNull Set<Integer> processedDirectoryOffsets,int tiffHeaderOffset,@NotNull final Metadata metadata,@NotNull RandomAccessReader reader) throws BufferBoundsException {
  Directory ifd0Directory=metadata.getDirectory(ExifIFD0Directory.class);
  if (ifd0Directory == null)   return;
  String cameraModel=ifd0Directory.getString(ExifIFD0Directory.TAG_MAKE);
  final String firstThreeChars=reader.getString(subdirOffset,3);
  final String firstFourChars=reader.getString(subdirOffset,4);
  final String firstFiveChars=reader.getString(subdirOffset,5);
  final String firstSixChars=reader.getString(subdirOffset,6);
  final String firstSevenChars=reader.getString(subdirOffset,7);
  final String firstEightChars=reader.getString(subdirOffset,8);
  final String firstTwelveChars=reader.getString(subdirOffset,12);
  if ("String_Node_Str".equals(firstFiveChars) || "String_Node_Str".equals(firstFiveChars) || "String_Node_Str".equals(firstFourChars)) {
    processDirectory(metadata.getOrCreateDirectory(OlympusMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 8,tiffHeaderOffset,metadata,reader);
  }
 else   if (cameraModel != null && cameraModel.trim().toUpperCase().startsWith("String_Node_Str")) {
    if ("String_Node_Str".equals(firstFiveChars)) {
switch (reader.getUInt8(subdirOffset + 6)) {
case 1:
        processDirectory(metadata.getOrCreateDirectory(NikonType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 8,tiffHeaderOffset,metadata,reader);
      break;
case 2:
    processDirectory(metadata.getOrCreateDirectory(NikonType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 18,subdirOffset + 10,metadata,reader);
  break;
default :
ifd0Directory.addError("String_Node_Str");
break;
}
}
 else {
processDirectory(metadata.getOrCreateDirectory(NikonType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equals(firstEightChars)) {
processDirectory(metadata.getOrCreateDirectory(SonyType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 12,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstTwelveChars)) {
boolean isMotorola=reader.isMotorolaByteOrder();
reader.setMotorolaByteOrder(true);
processDirectory(metadata.getOrCreateDirectory(SonyType6MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 20,tiffHeaderOffset,metadata,reader);
reader.setMotorolaByteOrder(isMotorola);
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equals(firstEightChars)) {
processDirectory(metadata.getOrCreateDirectory(SigmaMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 10,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstThreeChars)) {
processDirectory(metadata.getOrCreateDirectory(KodakMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 20,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equalsIgnoreCase(cameraModel)) {
processDirectory(metadata.getOrCreateDirectory(CanonMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if (cameraModel != null && cameraModel.toUpperCase().startsWith("String_Node_Str")) {
if ("String_Node_Str".equals(firstSixChars)) processDirectory(metadata.getOrCreateDirectory(CasioType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 6,tiffHeaderOffset,metadata,reader);
 else processDirectory(metadata.getOrCreateDirectory(CasioType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equalsIgnoreCase(cameraModel)) {
boolean byteOrderBefore=reader.isMotorolaByteOrder();
reader.setMotorolaByteOrder(false);
int ifdStart=subdirOffset + reader.getInt32(subdirOffset + 8);
processDirectory(metadata.getOrCreateDirectory(FujifilmMakernoteDirectory.class),processedDirectoryOffsets,ifdStart,tiffHeaderOffset,metadata,reader);
reader.setMotorolaByteOrder(byteOrderBefore);
}
 else if (cameraModel != null && cameraModel.toUpperCase().startsWith("String_Node_Str")) {
processDirectory(metadata.getOrCreateDirectory(OlympusMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstSevenChars)) {
processDirectory(metadata.getOrCreateDirectory(KyoceraMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 22,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(reader.getString(subdirOffset,12))) {
processDirectory(metadata.getOrCreateDirectory(PanasonicMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 12,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstFourChars)) {
processDirectory(metadata.getOrCreateDirectory(CasioType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 6,subdirOffset,metadata,reader);
}
 else if (cameraModel != null && (cameraModel.toUpperCase().startsWith("String_Node_Str") || cameraModel.toUpperCase().startsWith("String_Node_Str"))) {
processDirectory(metadata.getOrCreateDirectory(PentaxMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,subdirOffset,metadata,reader);
}
 else {
}
}

Fixed version (ground truth):
private void processMakerNote(int subdirOffset,@NotNull Set<Integer> processedDirectoryOffsets,int tiffHeaderOffset,@NotNull final Metadata metadata,@NotNull RandomAccessReader reader) throws BufferBoundsException {
  Directory ifd0Directory=metadata.getDirectory(ExifIFD0Directory.class);
  if (ifd0Directory == null)   return;
  String cameraModel=ifd0Directory.getString(ExifIFD0Directory.TAG_MAKE);
  final String firstThreeChars=reader.getString(subdirOffset,3);
  final String firstFourChars=reader.getString(subdirOffset,4);
  final String firstFiveChars=reader.getString(subdirOffset,5);
  final String firstSixChars=reader.getString(subdirOffset,6);
  final String firstSevenChars=reader.getString(subdirOffset,7);
  final String firstEightChars=reader.getString(subdirOffset,8);
  final String firstTwelveChars=reader.getString(subdirOffset,12);
  if ("String_Node_Str".equals(firstFiveChars) || "String_Node_Str".equals(firstFiveChars) || "String_Node_Str".equals(firstFourChars)) {
    processDirectory(metadata.getOrCreateDirectory(OlympusMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 8,tiffHeaderOffset,metadata,reader);
  }
 else   if (cameraModel != null && cameraModel.trim().toUpperCase().startsWith("String_Node_Str")) {
    if ("String_Node_Str".equals(firstFiveChars)) {
switch (reader.getUInt8(subdirOffset + 6)) {
case 1:
        processDirectory(metadata.getOrCreateDirectory(NikonType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 8,tiffHeaderOffset,metadata,reader);
      break;
case 2:
    processDirectory(metadata.getOrCreateDirectory(NikonType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 18,subdirOffset + 10,metadata,reader);
  break;
default :
ifd0Directory.addError("String_Node_Str");
break;
}
}
 else {
processDirectory(metadata.getOrCreateDirectory(NikonType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equals(firstEightChars)) {
processDirectory(metadata.getOrCreateDirectory(SonyType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 12,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstTwelveChars)) {
boolean isMotorola=reader.isMotorolaByteOrder();
reader.setMotorolaByteOrder(true);
processDirectory(metadata.getOrCreateDirectory(SonyType6MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 20,tiffHeaderOffset,metadata,reader);
reader.setMotorolaByteOrder(isMotorola);
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equals(firstEightChars)) {
processDirectory(metadata.getOrCreateDirectory(SigmaMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 10,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstThreeChars)) {
processDirectory(metadata.getOrCreateDirectory(KodakMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 20,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equalsIgnoreCase(cameraModel)) {
processDirectory(metadata.getOrCreateDirectory(CanonMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if (cameraModel != null && cameraModel.toUpperCase().startsWith("String_Node_Str")) {
if ("String_Node_Str".equals(firstSixChars)) processDirectory(metadata.getOrCreateDirectory(CasioType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 6,tiffHeaderOffset,metadata,reader);
 else processDirectory(metadata.getOrCreateDirectory(CasioType1MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstEightChars) || "String_Node_Str".equalsIgnoreCase(cameraModel)) {
boolean byteOrderBefore=reader.isMotorolaByteOrder();
reader.setMotorolaByteOrder(false);
int ifdStart=subdirOffset + reader.getInt32(subdirOffset + 8);
processDirectory(metadata.getOrCreateDirectory(FujifilmMakernoteDirectory.class),processedDirectoryOffsets,ifdStart,subdirOffset,metadata,reader);
reader.setMotorolaByteOrder(byteOrderBefore);
}
 else if (cameraModel != null && cameraModel.toUpperCase().startsWith("String_Node_Str")) {
processDirectory(metadata.getOrCreateDirectory(OlympusMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstSevenChars)) {
processDirectory(metadata.getOrCreateDirectory(KyoceraMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 22,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(reader.getString(subdirOffset,12))) {
processDirectory(metadata.getOrCreateDirectory(PanasonicMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 12,tiffHeaderOffset,metadata,reader);
}
 else if ("String_Node_Str".equals(firstFourChars)) {
processDirectory(metadata.getOrCreateDirectory(CasioType2MakernoteDirectory.class),processedDirectoryOffsets,subdirOffset + 6,subdirOffset,metadata,reader);
}
 else if (cameraModel != null && (cameraModel.toUpperCase().startsWith("String_Node_Str") || cameraModel.toUpperCase().startsWith("String_Node_Str"))) {
processDirectory(metadata.getOrCreateDirectory(PentaxMakernoteDirectory.class),processedDirectoryOffsets,subdirOffset,subdirOffset,metadata,reader);
}
 else {
}
}