Program: 25751
Project: 25751
Buggy source:
/** 
 * Proceses a HTTP request from a client.
 * @param out       the output stream to a client
 * @param cmd       the command received from a client
 */
public void doReply(InputStream in,OutputStream out,String cmd) throws IOException, BadHttpRequest {
  int len;
  int fileType;
  String filename, urlName;
  if (cmd.startsWith("String_Node_Str"))   filename=urlName=cmd.substring(5,cmd.indexOf(' ',5));
 else   throw new BadHttpRequest();
  if (filename.endsWith("String_Node_Str"))   fileType=typeClass;
 else   if (filename.endsWith("String_Node_Str") || filename.endsWith("String_Node_Str"))   fileType=typeHtml;
 else   if (filename.endsWith("String_Node_Str"))   fileType=typeGif;
 else   if (filename.endsWith("String_Node_Str"))   fileType=typeJpeg;
 else   fileType=typeText;
  len=filename.length();
  if (fileType == typeClass && letUsersSendClassfile(out,filename,len))   return;
  checkFilename(filename,len);
  if (htmlfileBase != null)   filename=htmlfileBase + filename;
  if (File.separatorChar != '/')   filename=filename.replace('/',File.separatorChar);
  File file=new File(filename);
  if (file.canRead()) {
    sendHeader(out,file.length(),fileType);
    FileInputStream fin=new FileInputStream(file);
    for (; ; ) {
      len=fin.read(filebuffer);
      if (len <= 0)       break;
 else       out.write(filebuffer,0,len);
    }
    fin.close();
    return;
  }
  if (fileType == typeClass) {
    InputStream fin=getClass().getResourceAsStream("String_Node_Str" + urlName);
    if (fin != null) {
      ByteArrayOutputStream barray=new ByteArrayOutputStream();
      for (; ; ) {
        len=fin.read(filebuffer);
        if (len <= 0)         break;
 else         barray.write(filebuffer,0,len);
      }
      byte[] classfile=barray.toByteArray();
      sendHeader(out,classfile.length,typeClass);
      out.write(classfile);
      fin.close();
      return;
    }
  }
  throw new BadHttpRequest();
}

Fixed version (ground truth):
/** 
 * Proceses a HTTP request from a client.
 * @param out       the output stream to a client
 * @param cmd       the command received from a client
 */
public void doReply(InputStream in,OutputStream out,String cmd) throws IOException, BadHttpRequest {
  int len;
  int fileType;
  String filename, urlName;
  if (cmd.startsWith("String_Node_Str"))   filename=urlName=cmd.substring(5,cmd.indexOf(' ',5));
 else   throw new BadHttpRequest();
  if (filename.endsWith("String_Node_Str"))   fileType=typeClass;
 else   if (filename.endsWith("String_Node_Str") || filename.endsWith("String_Node_Str"))   fileType=typeHtml;
 else   if (filename.endsWith("String_Node_Str"))   fileType=typeGif;
 else   if (filename.endsWith("String_Node_Str"))   fileType=typeJpeg;
 else   fileType=typeText;
  len=filename.length();
  if (fileType == typeClass && letUsersSendClassfile(out,filename,len))   return;
  checkFilename(filename,len);
  if (htmlfileBase != null)   filename=htmlfileBase + filename;
  if (File.separatorChar != '/')   filename=filename.replace('/',File.separatorChar);
  File file=new File(filename);
  if (file.canRead()) {
    sendHeader(out,file.length(),fileType);
    FileInputStream fin=new FileInputStream(file);
    byte[] filebuffer=new byte[4096];
    for (; ; ) {
      len=fin.read(filebuffer);
      if (len <= 0)       break;
 else       out.write(filebuffer,0,len);
    }
    fin.close();
    return;
  }
  if (fileType == typeClass) {
    InputStream fin=getClass().getResourceAsStream("String_Node_Str" + urlName);
    if (fin != null) {
      ByteArrayOutputStream barray=new ByteArrayOutputStream();
      byte[] filebuffer=new byte[4096];
      for (; ; ) {
        len=fin.read(filebuffer);
        if (len <= 0)         break;
 else         barray.write(filebuffer,0,len);
      }
      byte[] classfile=barray.toByteArray();
      sendHeader(out,classfile.length,typeClass);
      out.write(classfile);
      fin.close();
      return;
    }
  }
  throw new BadHttpRequest();
}