Program: 28325
Project: 28325
Buggy source:
/** 
 * Constructs the CGI environment to be supplied to the invoked CGI script; relies heavily on Servlet API methods and findCGI
 * @param req request associated with the CGIinvokation
 * @return   true if environment was set OK, false if therewas a problem and no environment was set
 */
protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException {
  Hashtable<String,String> envp=new Hashtable<String,String>();
  envp.putAll(shellEnv);
  String sPathInfoOrig=null;
  String sPathInfoCGI=null;
  String sPathTranslatedCGI=null;
  String sCGIFullPath=null;
  String sCGIScriptName=null;
  String sCGIFullName=null;
  String sCGIName=null;
  String[] sCGINames;
  sPathInfoOrig=this.pathInfo;
  sPathInfoOrig=sPathInfoOrig == null ? "String_Node_Str" : sPathInfoOrig;
  if (webAppRootDir == null) {
    webAppRootDir=tmpDir.toString();
    expandCGIScript();
  }
  sCGINames=findCGI(sPathInfoOrig,webAppRootDir,contextPath,servletPath,cgiPathPrefix);
  sCGIFullPath=sCGINames[0];
  sCGIScriptName=sCGINames[1];
  sCGIFullName=sCGINames[2];
  sCGIName=sCGINames[3];
  if (sCGIFullPath == null || sCGIScriptName == null || sCGIFullName == null || sCGIName == null) {
    return false;
  }
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getServerName()));
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getProtocol()));
  int port=req.getServerPort();
  Integer iPort=(port == 0 ? Integer.valueOf(-1) : Integer.valueOf(port));
  envp.put("String_Node_Str",iPort.toString());
  envp.put("String_Node_Str",nullsToBlanks(req.getMethod()));
  envp.put("String_Node_Str",stripRequestURI(nullsToBlanks(req.getRequestURI())));
  if (pathInfo == null || (pathInfo.substring(sCGIFullName.length()).length() <= 0)) {
    sPathInfoCGI="String_Node_Str";
  }
 else {
    sPathInfoCGI=pathInfo.substring(sCGIFullName.length());
  }
  envp.put("String_Node_Str",sPathInfoCGI);
  if (sPathInfoCGI != null && !("String_Node_Str".equals(sPathInfoCGI))) {
    sPathTranslatedCGI=context.getRealPath(sPathInfoCGI);
  }
  if (sPathTranslatedCGI == null || "String_Node_Str".equals(sPathTranslatedCGI)) {
  }
 else {
    envp.put("String_Node_Str",nullsToBlanks(sPathTranslatedCGI));
  }
  envp.put("String_Node_Str",nullsToBlanks(sCGIScriptName));
  envp.put("String_Node_Str",nullsToBlanks(req.getQueryString()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteHost()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteAddr()));
  envp.put("String_Node_Str",nullsToBlanks(req.getAuthType()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteUser()));
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getContentType()));
  int contentLength=req.getContentLength();
  String sContentLength=(contentLength <= 0 ? "String_Node_Str" : (Integer.valueOf(contentLength)).toString());
  envp.put("String_Node_Str",sContentLength);
  Enumeration<String> headers=req.getHeaderNames();
  String header=null;
  while (headers.hasMoreElements()) {
    header=null;
    header=(headers.nextElement()).toUpperCase(Locale.ENGLISH);
    if ("String_Node_Str".equalsIgnoreCase(header) || "String_Node_Str".equalsIgnoreCase(header)) {
    }
 else {
      envp.put("String_Node_Str" + header.replace('-','_'),req.getHeader(header));
    }
  }
  File fCGIFullPath=new File(sCGIFullPath);
  command=fCGIFullPath.getCanonicalPath();
  envp.put("String_Node_Str",command);
  envp.put("String_Node_Str",command);
  this.env=envp;
  return true;
}

Fixed version (ground truth):
/** 
 * Constructs the CGI environment to be supplied to the invoked CGI script; relies heavily on Servlet API methods and findCGI
 * @param req request associated with the CGIinvokation
 * @return   true if environment was set OK, false if therewas a problem and no environment was set
 */
protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException {
  Hashtable<String,String> envp=new Hashtable<String,String>();
  envp.putAll(shellEnv);
  String sPathInfoOrig=null;
  String sPathInfoCGI=null;
  String sPathTranslatedCGI=null;
  String sCGIFullPath=null;
  String sCGIScriptName=null;
  String sCGIFullName=null;
  String sCGIName=null;
  String[] sCGINames;
  sPathInfoOrig=this.pathInfo;
  sPathInfoOrig=sPathInfoOrig == null ? "String_Node_Str" : sPathInfoOrig;
  if (webAppRootDir == null) {
    webAppRootDir=tmpDir.toString();
    expandCGIScript();
  }
  sCGINames=findCGI(sPathInfoOrig,webAppRootDir,contextPath,servletPath,cgiPathPrefix);
  sCGIFullPath=sCGINames[0];
  sCGIScriptName=sCGINames[1];
  sCGIFullName=sCGINames[2];
  sCGIName=sCGINames[3];
  if (sCGIFullPath == null || sCGIScriptName == null || sCGIFullName == null || sCGIName == null) {
    return false;
  }
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getServerName()));
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getProtocol()));
  int port=req.getServerPort();
  Integer iPort=(port == 0 ? Integer.valueOf(-1) : Integer.valueOf(port));
  envp.put("String_Node_Str",iPort.toString());
  envp.put("String_Node_Str",nullsToBlanks(req.getMethod()));
  envp.put("String_Node_Str",stripRequestURI(nullsToBlanks(req.getRequestURI())));
  if (pathInfo == null || (pathInfo.substring(sCGIFullName.length()).length() <= 0)) {
    sPathInfoCGI="String_Node_Str";
  }
 else {
    sPathInfoCGI=pathInfo.substring(sCGIFullName.length());
  }
  envp.put("String_Node_Str",sPathInfoCGI);
  if (!("String_Node_Str".equals(sPathInfoCGI))) {
    sPathTranslatedCGI=context.getRealPath(sPathInfoCGI);
  }
  if (sPathTranslatedCGI == null || "String_Node_Str".equals(sPathTranslatedCGI)) {
  }
 else {
    envp.put("String_Node_Str",nullsToBlanks(sPathTranslatedCGI));
  }
  envp.put("String_Node_Str",nullsToBlanks(sCGIScriptName));
  envp.put("String_Node_Str",nullsToBlanks(req.getQueryString()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteHost()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteAddr()));
  envp.put("String_Node_Str",nullsToBlanks(req.getAuthType()));
  envp.put("String_Node_Str",nullsToBlanks(req.getRemoteUser()));
  envp.put("String_Node_Str","String_Node_Str");
  envp.put("String_Node_Str",nullsToBlanks(req.getContentType()));
  int contentLength=req.getContentLength();
  String sContentLength=(contentLength <= 0 ? "String_Node_Str" : (Integer.valueOf(contentLength)).toString());
  envp.put("String_Node_Str",sContentLength);
  Enumeration<String> headers=req.getHeaderNames();
  String header=null;
  while (headers.hasMoreElements()) {
    header=null;
    header=(headers.nextElement()).toUpperCase(Locale.ENGLISH);
    if ("String_Node_Str".equalsIgnoreCase(header) || "String_Node_Str".equalsIgnoreCase(header)) {
    }
 else {
      envp.put("String_Node_Str" + header.replace('-','_'),req.getHeader(header));
    }
  }
  File fCGIFullPath=new File(sCGIFullPath);
  command=fCGIFullPath.getCanonicalPath();
  envp.put("String_Node_Str",command);
  envp.put("String_Node_Str",command);
  this.env=envp;
  return true;
}