Program: 4844
Project: 4844
Buggy source:
/** 
 * Reads the HTTP header sent by the requesting client -- note that the 'GET' portion of the request header has already been read.
 * @throws <tt>IOException</tt> if there are any io issues while readingthe header
 */
private void readHeader() throws IOException {
  _uploadBegin=0;
  _uploadEnd=0;
  String userAgent;
  _clientAcceptsXGnutellaQueryreplies=false;
  ByteReader br=new ByteReader(_socket.getInputStream());
  while (true) {
    String str=br.readLine();
    debug("String_Node_Str" + str);
    if ((str == null) || (str.equals("String_Node_Str")))     break;
 else     if (str.toUpperCase().indexOf("String_Node_Str") != -1) {
      String sub;
      try {
        sub=str.substring(5);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      sub=sub.trim();
      int colon=sub.indexOf("String_Node_Str");
      String host=sub.substring(0,colon);
      host=host.trim();
      String sport=sub.substring(colon + 1);
      sport=sport.trim();
      int port;
      try {
        port=java.lang.Integer.parseInt(sport);
      }
 catch (      NumberFormatException e) {
        throw new IOException();
      }
      _chatEnabled=true;
      _chatHost=host;
      _chatPort=port;
    }
 else     if (indexOfIgnoreCase(str,"String_Node_Str") == 0) {
      String sub;
      String second;
      try {
        int i=str.indexOf("String_Node_Str");
        if (i < 0)         throw new IOException();
        i+=6;
        sub=str.substring(i);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      sub=sub.trim();
      char c;
      try {
        c=sub.charAt(0);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      if (c == '-') {
        try {
          second=sub.substring(1);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        second=second.trim();
        try {
          _uploadBegin=Math.max(0,_fileSize - Integer.parseInt(second));
          _uploadEnd=_fileSize;
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
      }
 else {
        int dash=sub.indexOf("String_Node_Str");
        String first;
        try {
          first=sub.substring(0,dash);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        first=first.trim();
        try {
          _uploadBegin=java.lang.Integer.parseInt(first);
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
        try {
          second=sub.substring(dash + 1);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        second=second.trim();
        if (!second.equals("String_Node_Str"))         try {
          _uploadEnd=java.lang.Integer.parseInt(second) + 1;
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
      }
    }
 else     if (indexOfIgnoreCase(str,"String_Node_Str") != -1) {
      if (SettingsManager.instance().getAllowBrowser() == false && !(_stateNum == BROWSE_HOST) && !(_fileName.toUpperCase().startsWith("String_Node_Str"))) {
        if ((str.indexOf("String_Node_Str") != -1) || (str.indexOf("String_Node_Str") != -1) || (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)) {
          throw new FreeloaderUploadingException();
        }
      }
      userAgent=str.substring(11).trim();
    }
 else     if (HTTPHeaderName.CONTENT_URN.matchesStartOfString(str)) {
      URN requestedURN=HTTPUploader.readContentUrn(str);
      if (requestedURN == null) {
        setState(FILE_NOT_FOUND);
      }
      if (_fileDesc != null) {
        if (!_fileDesc.equals(_fileManager.getFileDescForUrn(requestedURN))) {
          setState(FILE_NOT_FOUND);
        }
      }
    }
 else     if (HTTPHeaderName.ALT_LOCATION.matchesStartOfString(str)) {
      if (_alternateLocationCollection == null) {
        _alternateLocationCollection=new AlternateLocationCollection();
      }
      HTTPUploader.readAlternateLocations(str,_alternateLocationCollection);
    }
    if (indexOfIgnoreCase(str,"String_Node_Str") != -1) {
      if (indexOfIgnoreCase(str,Constants.QUERYREPLY_MIME_TYPE) != -1) {
        _clientAcceptsXGnutellaQueryreplies=true;
      }
    }
  }
  if (_uploadEnd == 0)   _uploadEnd=_fileSize;
}

Fixed version (ground truth):
/** 
 * Reads the HTTP header sent by the requesting client -- note that the 'GET' portion of the request header has already been read.
 * @throws <tt>IOException</tt> if there are any io issues while readingthe header
 */
private void readHeader() throws IOException {
  _uploadBegin=0;
  _uploadEnd=0;
  String userAgent;
  _clientAcceptsXGnutellaQueryreplies=false;
  ByteReader br=new ByteReader(_socket.getInputStream());
  while (true) {
    String str=br.readLine();
    debug("String_Node_Str" + str);
    if ((str == null) || (str.equals("String_Node_Str")))     break;
 else     if (str.toUpperCase().indexOf("String_Node_Str") != -1) {
      String sub;
      try {
        sub=str.substring(5);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      sub=sub.trim();
      int colon=sub.indexOf("String_Node_Str");
      String host=sub.substring(0,colon);
      host=host.trim();
      String sport=sub.substring(colon + 1);
      sport=sport.trim();
      int port;
      try {
        port=java.lang.Integer.parseInt(sport);
      }
 catch (      NumberFormatException e) {
        throw new IOException();
      }
      _chatEnabled=true;
      _chatHost=host;
      _chatPort=port;
    }
 else     if (indexOfIgnoreCase(str,"String_Node_Str") == 0) {
      String sub;
      String second;
      try {
        int i=str.indexOf("String_Node_Str");
        if (i < 0)         throw new IOException();
        i+=6;
        sub=str.substring(i);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      sub=sub.trim();
      char c;
      try {
        c=sub.charAt(0);
      }
 catch (      IndexOutOfBoundsException e) {
        throw new IOException();
      }
      if (c == '-') {
        try {
          second=sub.substring(1);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        second=second.trim();
        try {
          _uploadBegin=Math.max(0,_fileSize - Integer.parseInt(second));
          _uploadEnd=_fileSize;
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
      }
 else {
        int dash=sub.indexOf("String_Node_Str");
        String first;
        try {
          first=sub.substring(0,dash);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        first=first.trim();
        try {
          _uploadBegin=java.lang.Integer.parseInt(first);
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
        try {
          second=sub.substring(dash + 1);
        }
 catch (        IndexOutOfBoundsException e) {
          throw new IOException();
        }
        second=second.trim();
        if (!second.equals("String_Node_Str"))         try {
          _uploadEnd=java.lang.Integer.parseInt(second) + 1;
        }
 catch (        NumberFormatException e) {
          throw new IOException();
        }
      }
    }
 else     if (indexOfIgnoreCase(str,"String_Node_Str") != -1) {
      if (SettingsManager.instance().getAllowBrowser() == false && !(_stateNum == BROWSE_HOST) && !(_fileName.toUpperCase().startsWith("String_Node_Str"))) {
        if ((str.indexOf("String_Node_Str") != -1) || (str.indexOf("String_Node_Str") != -1) || (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)|| (str.indexOf("String_Node_Str") != -1)) {
          throw new FreeloaderUploadingException();
        }
      }
      userAgent=str.substring(11).trim();
    }
 else     if (HTTPHeaderName.CONTENT_URN.matchesStartOfString(str)) {
      URN requestedURN=HTTPUploader.readContentUrn(str);
      if (requestedURN == null) {
        setState(FILE_NOT_FOUND);
      }
      if (_fileDesc != null) {
        if (!_fileDesc.containsUrn(requestedURN)) {
          setState(FILE_NOT_FOUND);
        }
      }
    }
 else     if (HTTPHeaderName.ALT_LOCATION.matchesStartOfString(str)) {
      if (_alternateLocationCollection == null) {
        _alternateLocationCollection=new AlternateLocationCollection();
      }
      HTTPUploader.readAlternateLocations(str,_alternateLocationCollection);
    }
    if (indexOfIgnoreCase(str,"String_Node_Str") != -1) {
      if (indexOfIgnoreCase(str,Constants.QUERYREPLY_MIME_TYPE) != -1) {
        _clientAcceptsXGnutellaQueryreplies=true;
      }
    }
  }
  if (_uploadEnd == 0)   _uploadEnd=_fileSize;
}