Program: 192504
Project: 192504
Buggy source:
private String readExifEntryValue(ByteOrderAwarenessDataInputStream dataInputStream,int dataFormat,int numberOfComponents) throws IOException {
switch (dataFormat) {
case IFD_FORMAT_BYTE:
{
      return String.valueOf(dataInputStream.readByte());
    }
case IFD_FORMAT_SBYTE:
{
    return String.valueOf(dataInputStream.readByte() & 0xff);
  }
case IFD_FORMAT_USHORT:
{
  return String.valueOf(dataInputStream.readUnsignedShort());
}
case IFD_FORMAT_SSHORT:
{
return String.valueOf(dataInputStream.readUnsignedInt());
}
case IFD_FORMAT_ULONG:
{
return String.valueOf(dataInputStream.readInt());
}
case IFD_FORMAT_SLONG:
{
return String.valueOf(dataInputStream.readInt());
}
case IFD_FORMAT_URATIONAL:
case IFD_FORMAT_SRATIONAL:
{
int numerator=dataInputStream.readInt();
int denominator=dataInputStream.readInt();
return numerator + "String_Node_Str" + denominator;
}
case IFD_FORMAT_SINGLE:
{
return String.valueOf(dataInputStream.readFloat());
}
case IFD_FORMAT_DOUBLE:
{
return String.valueOf(dataInputStream.readDouble());
}
case IFD_FORMAT_UNDEFINED:
case IFD_FORMAT_STRING:
{
byte[] bytes=new byte[numberOfComponents];
dataInputStream.readFully(bytes);
int index=0;
if (numberOfComponents >= EXIF_ASCII_PREFIX.length) {
boolean same=true;
for (int i=0; i < EXIF_ASCII_PREFIX.length; ++i) {
if (bytes[i] != EXIF_ASCII_PREFIX[i]) {
same=false;
break;
}
}
if (same) {
index=EXIF_ASCII_PREFIX.length;
}
}
StringBuilder stringBuilder=new StringBuilder();
while (true) {
int ch=bytes[index];
if (ch < 0) throw new EOFException();
if (ch == 0) break;
if (ch >= 32) stringBuilder.append((char)ch);
 else stringBuilder.append('?');
++index;
if (index == numberOfComponents) break;
}
return stringBuilder.toString();
}
default :
{
return null;
}
}
}

Fixed version (ground truth):
private String readExifEntryValue(ByteOrderAwarenessDataInputStream dataInputStream,int dataFormat,int numberOfComponents) throws IOException {
switch (dataFormat) {
case IFD_FORMAT_BYTE:
{
      return String.valueOf(dataInputStream.readByte());
    }
case IFD_FORMAT_SBYTE:
{
    return String.valueOf(dataInputStream.readByte() & 0xff);
  }
case IFD_FORMAT_USHORT:
{
  return String.valueOf(dataInputStream.readUnsignedShort());
}
case IFD_FORMAT_SSHORT:
{
return String.valueOf(dataInputStream.readUnsignedInt());
}
case IFD_FORMAT_ULONG:
{
return String.valueOf(dataInputStream.readInt());
}
case IFD_FORMAT_SLONG:
{
return String.valueOf(dataInputStream.readInt());
}
case IFD_FORMAT_URATIONAL:
case IFD_FORMAT_SRATIONAL:
{
int numerator=dataInputStream.readInt();
int denominator=dataInputStream.readInt();
return numerator + "String_Node_Str" + denominator;
}
case IFD_FORMAT_SINGLE:
{
return String.valueOf(dataInputStream.readFloat());
}
case IFD_FORMAT_DOUBLE:
{
return String.valueOf(dataInputStream.readDouble());
}
case IFD_FORMAT_UNDEFINED:
case IFD_FORMAT_STRING:
{
byte[] bytes=new byte[numberOfComponents];
dataInputStream.readFully(bytes);
int index=0;
if (numberOfComponents >= EXIF_ASCII_PREFIX.length) {
boolean same=true;
for (int i=0; i < EXIF_ASCII_PREFIX.length; ++i) {
if (bytes[i] != EXIF_ASCII_PREFIX[i]) {
same=false;
break;
}
}
if (same) {
index=EXIF_ASCII_PREFIX.length;
}
}
StringBuilder stringBuilder=new StringBuilder();
while (true) {
int ch=bytes[index];
if (ch == 0) break;
if (ch >= 32) stringBuilder.append((char)ch);
 else stringBuilder.append('?');
++index;
if (index == numberOfComponents) break;
}
return stringBuilder.toString();
}
default :
{
return null;
}
}
}