Program: 80836
Project: 80836
Buggy source:
public Map<String,Object> parse(HttpServletRequest req,String charset,FilePool tmps) throws UploadException {
  UploadInfo info=Uploads.createInfo(req);
  StreamBuffer sb=null;
  InputStream ins=null;
  try {
    Map<String,Object> params=Uploads.createParamsMap(req);
    ins=req.getInputStream();
    if (!(ins instanceof BufferedInputStream)) {
      if (bufferSize > 0)       ins=new BufferedInputStream(ins,bufferSize);
 else       ins=new BufferedInputStream(ins);
    }
    String contentType=req.getContentType();
    String s="String_Node_Str" + Http.multipart.getBoundary(contentType);
    char[] endValue=s.toCharArray();
    int[] right=new int[endValue.length];
    int cursor;
    int c=0;
    for (int i=0; i < s.length(); i++) {
      c=ins.read();
      info.current++;
    }
    while (c != -1) {
      cursor=0;
      right[cursor++]=ins.read();
      info.current++;
      if (right[0] == -1) {
        right[cursor++]=-1;
      }
 else {
        right[cursor++]=ins.read();
        info.current++;
      }
      if (right[1] == -1 || (right[0] == '-' && right[1] == '-'))       break;
      sb=new StreamBuffer();
      while (cursor < endName.length) {
        c=ins.read();
        if (c == -1)         break;
        info.current++;
        if (c == endName[cursor]) {
          right[cursor++]=c;
        }
 else {
          if (cursor > 0) {
            for (int i=0; i < cursor; i++)             sb.write(right[i]);
          }
          sb.write(c);
          cursor=0;
        }
      }
      FieldMeta meta=new FieldMeta(sb.toString(charset));
      cursor=0;
      if (meta.isFile()) {
        File tmp=null;
        OutputStream ots;
        if (Strings.isBlank(meta.getFileLocalPath())) {
          ots=new StringOutputStream(new StringBuilder());
        }
 else {
          tmp=tmps.createFile(meta.getFileExtension());
          ots=new BufferedOutputStream(new FileOutputStream(tmp));
        }
        while (c != -1 && cursor < endValue.length) {
          c=ins.read();
          info.current++;
          if (c == endValue[cursor]) {
            right[cursor++]=c;
          }
 else {
            if (cursor > 0) {
              for (int i=0; i < cursor; i++)               ots.write(right[i]);
            }
            ots.write(c);
            cursor=0;
          }
        }
        Streams.safeClose(ots);
        if (null != tmp && !Strings.isBlank(meta.getFileLocalPath()) && tmp.length() > 0)         params.put(meta.getName(),new TempFile(meta,tmp));
      }
 else {
        sb=new StreamBuffer();
        while (c != -1 && cursor < endValue.length) {
          c=ins.read();
          info.current++;
          if (c == endValue[cursor]) {
            right[cursor++]=c;
          }
 else {
            if (cursor > 0) {
              for (int i=0; i < cursor; i++)               sb.write(right[i]);
            }
            sb.write(c);
            cursor=0;
          }
        }
        params.put(meta.getName(),sb.toString(charset));
      }
    }
    return params;
  }
 catch (  IOException e) {
    throw new UploadException(e);
  }
 finally {
    Streams.safeClose(ins);
    Streams.safeClose(sb);
    if (null != req.getSession())     req.getSession().removeAttribute(UploadInfo.class.getName());
  }
}

Fixed version (ground truth):
public Map<String,Object> parse(HttpServletRequest req,UploadingContext context) throws UploadException {
  String charset=context.getCharset();
  FilePool tmps=context.getFilePool();
  UploadInfo info=Uploads.createInfo(req);
  StreamBuffer sb=null;
  InputStream ins=null;
  try {
    Map<String,Object> params=Uploads.createParamsMap(req);
    ins=req.getInputStream();
    if (!(ins instanceof BufferedInputStream)) {
      if (bufferSize > 0)       ins=new BufferedInputStream(ins,bufferSize);
 else       ins=new BufferedInputStream(ins);
    }
    String contentType=req.getContentType();
    String s="String_Node_Str" + Http.multipart.getBoundary(contentType);
    char[] endValue=s.toCharArray();
    int[] right=new int[endValue.length];
    int cursor;
    int c=0;
    for (int i=0; i < s.length(); i++) {
      c=ins.read();
      info.current++;
    }
    while (c != -1) {
      cursor=0;
      right[cursor++]=ins.read();
      info.current++;
      if (right[0] == -1) {
        right[cursor++]=-1;
      }
 else {
        right[cursor++]=ins.read();
        info.current++;
      }
      if (right[1] == -1 || (right[0] == '-' && right[1] == '-'))       break;
      sb=new StreamBuffer();
      while (cursor < endName.length) {
        c=ins.read();
        if (c == -1)         break;
        info.current++;
        if (c == endName[cursor]) {
          right[cursor++]=c;
        }
 else {
          if (cursor > 0) {
            for (int i=0; i < cursor; i++)             sb.write(right[i]);
          }
          sb.write(c);
          cursor=0;
        }
      }
      FieldMeta meta=new FieldMeta(sb.toString(charset));
      cursor=0;
      if (meta.isFile()) {
        File tmp=null;
        OutputStream ots;
        if (Strings.isBlank(meta.getFileLocalPath())) {
          ots=new StringOutputStream(new StringBuilder());
        }
 else {
          tmp=tmps.createFile(meta.getFileExtension());
          ots=new BufferedOutputStream(new FileOutputStream(tmp));
        }
        while (c != -1 && cursor < endValue.length) {
          c=ins.read();
          info.current++;
          if (c == endValue[cursor]) {
            right[cursor++]=c;
          }
 else {
            if (cursor > 0) {
              for (int i=0; i < cursor; i++)               ots.write(right[i]);
            }
            ots.write(c);
            cursor=0;
          }
        }
        Streams.safeClose(ots);
        if (null != tmp && !Strings.isBlank(meta.getFileLocalPath()) && tmp.length() > 0)         params.put(meta.getName(),new TempFile(meta,tmp));
      }
 else {
        sb=new StreamBuffer();
        while (c != -1 && cursor < endValue.length) {
          c=ins.read();
          info.current++;
          if (c == endValue[cursor]) {
            right[cursor++]=c;
          }
 else {
            if (cursor > 0) {
              for (int i=0; i < cursor; i++)               sb.write(right[i]);
            }
            sb.write(c);
            cursor=0;
          }
        }
        params.put(meta.getName(),sb.toString(charset));
      }
    }
    return params;
  }
 catch (  IOException e) {
    throw new UploadException(e);
  }
 finally {
    Streams.safeClose(ins);
    Streams.safeClose(sb);
    if (null != req.getSession())     req.getSession().removeAttribute(UploadInfo.class.getName());
  }
}