Program: 4682
Project: 4682
Buggy source:
/** 
 * Sends a GET request using an already open socket, and reads all  headers.  <p>
 * @param start The byte at which the HTTPDownloader should begin
 * @param stop the index just past the last byte to read;stop-1 is the last byte the HTTPDownloader should download <p>
 * @exception TryAgainLaterException the host is busy
 * @exception FileNotFoundException the host doesn't recognize the file
 * @exception NotSharingException the host isn't sharing files (BearShare)
 * @exception IOException miscellaneous  error 
 */
public void connectHTTP(int start,int stop,boolean supportQueueing) throws IOException, TryAgainLaterException, FileNotFoundException, NotSharingException, QueuedException {
  _amountToRead=stop - start;
  _amountRead=0;
  _initialReadingPoint=start;
  OutputStream os=_socket.getOutputStream();
  OutputStreamWriter osw=new OutputStreamWriter(os);
  BufferedWriter out=new BufferedWriter(osw);
  String startRange=java.lang.String.valueOf(_initialReadingPoint);
  out.write("String_Node_Str" + _rfd.getUrl().getFile() + "String_Node_Str");
  out.write("String_Node_Str" + _host + "String_Node_Str"+ _port+ "String_Node_Str");
  out.write("String_Node_Str" + CommonUtils.getHttpServer() + "String_Node_Str");
  if (supportQueueing)   out.write("String_Node_Str");
  AlternateLocationCollection alts=null;
  if (_alternateLocationsToSend != null) {
    alts=AlternateLocationCollection.createCollection(_alternateLocationsToSend.getSHA1Urn());
synchronized (_alternateLocationsToSend) {
      alts.addAlternateLocationCollection(_alternateLocationsToSend);
    }
  }
  URN sha1=_rfd.getSHA1Urn();
  if (sha1 != null)   HTTPUtils.writeHeader(HTTPHeaderName.GNUTELLA_CONTENT_URN,sha1,out);
  if (alts != null && alts.numberOfAlternateLocations() > 0) {
    HTTPUtils.writeHeader(HTTPHeaderName.ALT_LOCATION,alts,out);
  }
  out.write("String_Node_Str" + startRange + "String_Node_Str"+ (stop - 1)+ "String_Node_Str");
  SettingsManager sm=SettingsManager.instance();
  if (sm.getChatEnabled()) {
    int port;
    String host;
    if (sm.getForceIPAddress()) {
      port=sm.getForcedPort();
      host=sm.getForcedIPAddressString();
    }
 else {
      port=sm.getPort();
      host=_socket.getLocalAddress().getHostAddress();
    }
    out.write("String_Node_Str" + host + "String_Node_Str"+ port+ "String_Node_Str");
  }
  out.write("String_Node_Str");
  out.flush();
  readHeaders();
}

Fixed version (ground truth):
/** 
 * Sends a GET request using an already open socket, and reads all  headers.  <p>
 * @param start The byte at which the HTTPDownloader should begin
 * @param stop the index just past the last byte to read;stop-1 is the last byte the HTTPDownloader should download <p>
 * @exception TryAgainLaterException the host is busy
 * @exception FileNotFoundException the host doesn't recognize the file
 * @exception NotSharingException the host isn't sharing files (BearShare)
 * @exception IOException miscellaneous  error 
 */
public void connectHTTP(int start,int stop,boolean supportQueueing) throws IOException, TryAgainLaterException, FileNotFoundException, NotSharingException, QueuedException {
  _amountToRead=stop - start;
  _totalAmountRead+=_amountRead;
  _amountRead=0;
  _initialReadingPoint=start;
  OutputStream os=_socket.getOutputStream();
  OutputStreamWriter osw=new OutputStreamWriter(os);
  BufferedWriter out=new BufferedWriter(osw);
  String startRange=java.lang.String.valueOf(_initialReadingPoint);
  out.write("String_Node_Str" + _rfd.getUrl().getFile() + "String_Node_Str");
  out.write("String_Node_Str" + _host + "String_Node_Str"+ _port+ "String_Node_Str");
  out.write("String_Node_Str" + CommonUtils.getHttpServer() + "String_Node_Str");
  if (supportQueueing)   out.write("String_Node_Str");
  AlternateLocationCollection alts=null;
  if (_alternateLocationsToSend != null) {
    alts=AlternateLocationCollection.createCollection(_alternateLocationsToSend.getSHA1Urn());
synchronized (_alternateLocationsToSend) {
      alts.addAlternateLocationCollection(_alternateLocationsToSend);
    }
  }
  URN sha1=_rfd.getSHA1Urn();
  if (sha1 != null)   HTTPUtils.writeHeader(HTTPHeaderName.GNUTELLA_CONTENT_URN,sha1,out);
  if (alts != null && alts.numberOfAlternateLocations() > 0) {
    HTTPUtils.writeHeader(HTTPHeaderName.ALT_LOCATION,alts,out);
  }
  out.write("String_Node_Str" + startRange + "String_Node_Str"+ (stop - 1)+ "String_Node_Str");
  SettingsManager sm=SettingsManager.instance();
  if (sm.getChatEnabled()) {
    int port;
    String host;
    if (sm.getForceIPAddress()) {
      port=sm.getForcedPort();
      host=sm.getForcedIPAddressString();
    }
 else {
      port=sm.getPort();
      host=_socket.getLocalAddress().getHostAddress();
    }
    out.write("String_Node_Str" + host + "String_Node_Str"+ port+ "String_Node_Str");
  }
  out.write("String_Node_Str");
  out.flush();
  readHeaders();
}