Program: 174771
Project: 174771
Buggy source:
/** 
 * Exceute the WebDAV request
 * @exception WebDAVServerException
 */
protected void executeImpl() throws WebDAVServerException, Exception {
  FileFolderService fileFolderService=getFileFolderService();
  NodeRef rootNodeRef=getRootNodeRef();
  String path=getPath();
  String servletPath=getServletPath();
  FileInfo nodeInfo=null;
  try {
    nodeInfo=getDAVHelper().getNodeForPath(rootNodeRef,path,servletPath);
  }
 catch (  FileNotFoundException e) {
    throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
  }
  FileInfo realNodeInfo=nodeInfo;
  if (realNodeInfo.isLink()) {
    Path pathToNode=getNodeService().getPath(nodeInfo.getLinkNodeRef());
    if (pathToNode.size() > 2) {
      pathToNode=pathToNode.subPath(2,pathToNode.size() - 1);
    }
    String rootURL=WebDAV.getURLForPath(m_request,pathToNode.toDisplayPath(getNodeService(),getPermissionService()),true);
    if (rootURL.endsWith(WebDAVHelper.PathSeperator) == false) {
      rootURL=rootURL + WebDAVHelper.PathSeperator;
    }
    String fname=(String)getNodeService().getProperty(nodeInfo.getLinkNodeRef(),ContentModel.PROP_NAME);
    String webDavUrl=m_request.getServerName() + "String_Node_Str" + m_request.getServerPort()+ rootURL+ WebDAVHelper.encodeURL(fname,m_userAgent);
    StringBuilder urlStr=new StringBuilder();
    urlStr.append("String_Node_Str");
    urlStr.append("String_Node_Str");
    urlStr.append(webDavUrl);
    urlStr.append("String_Node_Str");
    m_response.setHeader(WebDAV.HEADER_CONTENT_TYPE,"String_Node_Str");
    m_response.setHeader(WebDAV.HEADER_CONTENT_LENGTH,String.valueOf(urlStr.length()));
    m_response.getWriter().write(urlStr.toString());
  }
 else   if (realNodeInfo.isFolder()) {
    if (!m_returnContent) {
      return;
    }
    m_response.setContentType("String_Node_Str");
    generateDirectoryListing(nodeInfo);
  }
 else {
    checkPreConditions(realNodeInfo);
    m_response.setHeader(WebDAV.HEADER_ETAG,getDAVHelper().makeQuotedETag(nodeInfo));
    Date modifiedDate=realNodeInfo.getModifiedDate();
    if (modifiedDate != null) {
      long modDate=DefaultTypeConverter.INSTANCE.longValue(modifiedDate);
      m_response.setHeader(WebDAV.HEADER_LAST_MODIFIED,WebDAV.formatHeaderDate(modDate));
    }
    ContentReader reader=fileFolderService.getReader(realNodeInfo.getNodeRef());
    reader=FileContentReader.getSafeContentReader((ContentReader)reader,I18NUtil.getMessage(FileContentReader.MSG_MISSING_CONTENT),realNodeInfo.getNodeRef(),reader);
    if (byteRanges != null && byteRanges.startsWith(RANGE_HEADER_UNIT_SPECIFIER)) {
      HttpRangeProcessor rangeProcessor=new HttpRangeProcessor(getContentService());
      String userAgent=m_request.getHeader(WebDAV.HEADER_USER_AGENT);
      if (m_returnContent) {
        rangeProcessor.processRange(m_response,reader,byteRanges.substring(6),realNodeInfo.getNodeRef(),ContentModel.PROP_CONTENT,reader.getMimetype(),userAgent);
      }
    }
 else {
      m_response.setHeader(WebDAV.HEADER_CONTENT_LENGTH,Long.toString(reader.getSize()));
      m_response.setHeader(WebDAV.HEADER_CONTENT_TYPE,reader.getMimetype());
      if (m_returnContent) {
        reader.getContent(m_response.getOutputStream());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Exceute the WebDAV request
 * @exception WebDAVServerException
 */
protected void executeImpl() throws WebDAVServerException, Exception {
  FileFolderService fileFolderService=getFileFolderService();
  NodeRef rootNodeRef=getRootNodeRef();
  String path=getPath();
  String servletPath=getServletPath();
  FileInfo nodeInfo=null;
  try {
    nodeInfo=getDAVHelper().getNodeForPath(rootNodeRef,path,servletPath);
  }
 catch (  FileNotFoundException e) {
    throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
  }
  FileInfo realNodeInfo=nodeInfo;
  if (realNodeInfo.isLink()) {
    Path pathToNode=getNodeService().getPath(nodeInfo.getLinkNodeRef());
    if (pathToNode.size() > 2) {
      pathToNode=pathToNode.subPath(2,pathToNode.size() - 1);
    }
    String rootURL=getDAVHelper().getURLForPath(m_request,pathToNode.toDisplayPath(getNodeService(),getPermissionService()),true);
    if (rootURL.endsWith(WebDAVHelper.PathSeperator) == false) {
      rootURL=rootURL + WebDAVHelper.PathSeperator;
    }
    String fname=(String)getNodeService().getProperty(nodeInfo.getLinkNodeRef(),ContentModel.PROP_NAME);
    String webDavUrl=m_request.getServerName() + "String_Node_Str" + m_request.getServerPort()+ rootURL+ WebDAVHelper.encodeURL(fname,m_userAgent);
    StringBuilder urlStr=new StringBuilder();
    urlStr.append("String_Node_Str");
    urlStr.append("String_Node_Str");
    urlStr.append(webDavUrl);
    urlStr.append("String_Node_Str");
    m_response.setHeader(WebDAV.HEADER_CONTENT_TYPE,"String_Node_Str");
    m_response.setHeader(WebDAV.HEADER_CONTENT_LENGTH,String.valueOf(urlStr.length()));
    m_response.getWriter().write(urlStr.toString());
  }
 else   if (realNodeInfo.isFolder()) {
    if (!m_returnContent) {
      return;
    }
    m_response.setContentType("String_Node_Str");
    generateDirectoryListing(nodeInfo);
  }
 else {
    checkPreConditions(realNodeInfo);
    m_response.setHeader(WebDAV.HEADER_ETAG,getDAVHelper().makeQuotedETag(nodeInfo));
    Date modifiedDate=realNodeInfo.getModifiedDate();
    if (modifiedDate != null) {
      long modDate=DefaultTypeConverter.INSTANCE.longValue(modifiedDate);
      m_response.setHeader(WebDAV.HEADER_LAST_MODIFIED,WebDAV.formatHeaderDate(modDate));
    }
    ContentReader reader=fileFolderService.getReader(realNodeInfo.getNodeRef());
    reader=FileContentReader.getSafeContentReader((ContentReader)reader,I18NUtil.getMessage(FileContentReader.MSG_MISSING_CONTENT),realNodeInfo.getNodeRef(),reader);
    if (byteRanges != null && byteRanges.startsWith(RANGE_HEADER_UNIT_SPECIFIER)) {
      HttpRangeProcessor rangeProcessor=new HttpRangeProcessor(getContentService());
      String userAgent=m_request.getHeader(WebDAV.HEADER_USER_AGENT);
      if (m_returnContent) {
        rangeProcessor.processRange(m_response,reader,byteRanges.substring(6),realNodeInfo.getNodeRef(),ContentModel.PROP_CONTENT,reader.getMimetype(),userAgent);
      }
    }
 else {
      m_response.setHeader(WebDAV.HEADER_CONTENT_LENGTH,Long.toString(reader.getSize()));
      m_response.setHeader(WebDAV.HEADER_CONTENT_TYPE,reader.getMimetype());
      if (m_returnContent) {
        reader.getContent(m_response.getOutputStream());
      }
    }
  }
}