Program: 50706
Project: 50706
Buggy source:
/** 
 * See the general contract of the <code>readUTF</code> method of <code>DataInput</code>. <p/> Bytes for this operation are read from the contained input stream.
 * @return a Unicode string.
 * @throws EOFException           if this input stream reaches the end before reading allthe bytes.
 * @throws IOException            if an I/O error occurs.
 * @throws UTFDataFormatException if the bytes do not represent a valid modified UTF-8encoding of a string.
 * @see java.io.DataInputStream#readUTF(java.io.DataInput)
 */
public final String readUTF() throws IOException {
  final int utflen=readUnsignedShort();
  byte[] bytearr=null;
  char[] chararr=null;
  bytearr=new byte[utflen];
  chararr=new char[utflen];
  int c, char2, char3;
  int count=0;
  int chararr_count=0;
  readFully(bytearr,0,utflen);
  while (count < utflen) {
    c=bytearr[count] & 0xff;
    if (c > 127)     break;
    count++;
    chararr[chararr_count++]=(char)c;
  }
  while (count < utflen) {
    c=bytearr[count] & 0xff;
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
      count++;
    chararr[chararr_count++]=(char)c;
  break;
case 12:
case 13:
count+=2;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=bytearr[count - 1];
if ((char2 & 0xC0) != 0x80) throw new UTFDataFormatException("String_Node_Str" + count);
chararr[chararr_count++]=(char)(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
count+=3;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=bytearr[count - 2];
char3=bytearr[count - 1];
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) throw new UTFDataFormatException("String_Node_Str" + (count - 1));
chararr[chararr_count++]=(char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break;
default :
throw new UTFDataFormatException("String_Node_Str" + count);
}
}
return new String(chararr,0,chararr_count);
}

Fixed version (ground truth):
/** 
 * See the general contract of the <code>readUTF</code> method of <code>DataInput</code>. <p/> Bytes for this operation are read from the contained input stream.
 * @return a Unicode string.
 * @throws EOFException           if this input stream reaches the end before reading allthe bytes.
 * @throws IOException            if an I/O error occurs.
 * @throws UTFDataFormatException if the bytes do not represent a valid modified UTF-8encoding of a string.
 * @see java.io.DataInputStream#readUTF(java.io.DataInput)
 */
public final String readUTF() throws IOException {
  final int utflen=readInt();
  byte[] bytearr=null;
  char[] chararr=null;
  bytearr=new byte[utflen];
  chararr=new char[utflen];
  int c, char2, char3;
  int count=0;
  int chararr_count=0;
  readFully(bytearr,0,utflen);
  while (count < utflen) {
    c=bytearr[count] & 0xff;
    if (c > 127)     break;
    count++;
    chararr[chararr_count++]=(char)c;
  }
  while (count < utflen) {
    c=bytearr[count] & 0xff;
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
      count++;
    chararr[chararr_count++]=(char)c;
  break;
case 12:
case 13:
count+=2;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=bytearr[count - 1];
if ((char2 & 0xC0) != 0x80) throw new UTFDataFormatException("String_Node_Str" + count);
chararr[chararr_count++]=(char)(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
count+=3;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=bytearr[count - 2];
char3=bytearr[count - 1];
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) throw new UTFDataFormatException("String_Node_Str" + (count - 1));
chararr[chararr_count++]=(char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break;
default :
throw new UTFDataFormatException("String_Node_Str" + count);
}
}
return new String(chararr,0,chararr_count);
}