Program: 52153
Project: 52153
Buggy source:
/** 
 * Process the upload of a new file!
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return Status or error flag which will be processed byUI-related code! (if STATUS_COMPLETE or 0 is returned, no errors occurred!)
 */
protected int processUploadFile(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  boolean formatKnown=true;
  boolean fileOK=false;
  BitstreamFormat bf=null;
  Bitstream b=null;
  Enumeration attNames=request.getAttributeNames();
  while (attNames.hasMoreElements()) {
    String attr=(String)attNames.nextElement();
    if (attr.endsWith("String_Node_Str")) {
      String param=attr.replace("String_Node_Str","String_Node_Str");
      String filePath=(String)request.getAttribute(param + "String_Node_Str");
      InputStream fileInputStream=(InputStream)request.getAttribute(param + "String_Node_Str");
      String fileDescription=(String)request.getAttribute(param + "String_Node_Str");
      if (fileDescription == null || fileDescription.length() == 0) {
        request.getParameter("String_Node_Str");
      }
      if (filePath == null || fileInputStream == null) {
        return STATUS_UPLOAD_ERROR;
      }
      if (subInfo == null) {
        return STATUS_INTEGRITY_ERROR;
      }
      Item item=subInfo.getSubmissionItem().getItem();
      Bundle[] bundles=item.getBundles("String_Node_Str");
      if (bundles.length < 1) {
        b=item.createSingleBitstream(fileInputStream,"String_Node_Str");
      }
 else {
        b=bundles[0].createBitstream(fileInputStream);
      }
      String noPath=filePath;
      while (noPath.indexOf('/') > -1) {
        noPath=noPath.substring(noPath.indexOf('/') + 1);
      }
      while (noPath.indexOf('\\') > -1) {
        noPath=noPath.substring(noPath.indexOf('\\') + 1);
      }
      b.setName(noPath);
      b.setSource(filePath);
      b.setDescription(fileDescription);
      bf=FormatIdentifier.guessFormat(context,b);
      b.setFormat(bf);
      b.update();
      item.update();
      if ((bf != null) && (bf.isInternal())) {
        log.warn("String_Node_Str");
        backoutBitstream(subInfo,b,item);
        return STATUS_UPLOAD_ERROR;
      }
      if (ConfigurationManager.getBooleanProperty("String_Node_Str","String_Node_Str")) {
        Curator curator=new Curator();
        curator.addTask("String_Node_Str").curate(item);
        int status=curator.getStatus("String_Node_Str");
        if (status == Curator.CURATE_ERROR) {
          backoutBitstream(subInfo,b,item);
          return STATUS_VIRUS_CHECKER_UNAVAILABLE;
        }
 else         if (status == Curator.CURATE_FAIL) {
          backoutBitstream(subInfo,b,item);
          return STATUS_CONTAINS_VIRUS;
        }
      }
      context.commit();
      subInfo.setBitstream(b);
      if (bf == null) {
        return STATUS_UNKNOWN_FORMAT;
      }
    }
  }
  return STATUS_COMPLETE;
}

Fixed version (ground truth):
/** 
 * Process the upload of a new file!
 * @param context current DSpace context
 * @param request current servlet request object
 * @param response current servlet response object
 * @param subInfo submission info object
 * @return Status or error flag which will be processed byUI-related code! (if STATUS_COMPLETE or 0 is returned, no errors occurred!)
 */
protected int processUploadFile(Context context,HttpServletRequest request,HttpServletResponse response,SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException {
  boolean formatKnown=true;
  boolean fileOK=false;
  BitstreamFormat bf=null;
  Bitstream b=null;
  Enumeration attNames=request.getAttributeNames();
  while (attNames.hasMoreElements()) {
    String attr=(String)attNames.nextElement();
    if (attr.endsWith("String_Node_Str")) {
      String param=attr.replace("String_Node_Str","String_Node_Str");
      String filePath=(String)request.getAttribute(param + "String_Node_Str");
      InputStream fileInputStream=(InputStream)request.getAttribute(param + "String_Node_Str");
      String fileDescription=(String)request.getAttribute(param + "String_Node_Str");
      if (fileDescription == null || fileDescription.length() == 0) {
        fileDescription=request.getParameter("String_Node_Str");
      }
      if (filePath == null || fileInputStream == null) {
        return STATUS_UPLOAD_ERROR;
      }
      if (subInfo == null) {
        return STATUS_INTEGRITY_ERROR;
      }
      Item item=subInfo.getSubmissionItem().getItem();
      Bundle[] bundles=item.getBundles("String_Node_Str");
      if (bundles.length < 1) {
        b=item.createSingleBitstream(fileInputStream,"String_Node_Str");
      }
 else {
        b=bundles[0].createBitstream(fileInputStream);
      }
      String noPath=filePath;
      while (noPath.indexOf('/') > -1) {
        noPath=noPath.substring(noPath.indexOf('/') + 1);
      }
      while (noPath.indexOf('\\') > -1) {
        noPath=noPath.substring(noPath.indexOf('\\') + 1);
      }
      b.setName(noPath);
      b.setSource(filePath);
      b.setDescription(fileDescription);
      bf=FormatIdentifier.guessFormat(context,b);
      b.setFormat(bf);
      b.update();
      item.update();
      if ((bf != null) && (bf.isInternal())) {
        log.warn("String_Node_Str");
        backoutBitstream(subInfo,b,item);
        return STATUS_UPLOAD_ERROR;
      }
      if (ConfigurationManager.getBooleanProperty("String_Node_Str","String_Node_Str")) {
        Curator curator=new Curator();
        curator.addTask("String_Node_Str").curate(item);
        int status=curator.getStatus("String_Node_Str");
        if (status == Curator.CURATE_ERROR) {
          backoutBitstream(subInfo,b,item);
          return STATUS_VIRUS_CHECKER_UNAVAILABLE;
        }
 else         if (status == Curator.CURATE_FAIL) {
          backoutBitstream(subInfo,b,item);
          return STATUS_CONTAINS_VIRUS;
        }
      }
      context.commit();
      subInfo.setBitstream(b);
      if (bf == null) {
        return STATUS_UNKNOWN_FORMAT;
      }
    }
  }
  return STATUS_COMPLETE;
}