Program: 4477
Project: 4477
Buggy source:
/** 
 * Returns the fully-qualified temporary download file for the given file/location pair.  The location of the file is determined by the INCOMPLETE_DIRECTORY property.  For example, getFile("test.txt", 1999) may return "C:\Program Files\LimeWire\Incomplete\T-1999-Test.txt".  The disk is not modified.<p> This method gives duplicate files the same temporary file, which is critical for resume and swarmed downloads.  That is, for all rfd_i and  rfd_j <pre> similar(rfd_i, rfd_j) <==> getFile(rfd_i).equals(getFile(rfd_j))<p>   </pre> It is imperative that the files are compared as in their canonical formats to preserve the integrity of the filesystem.  Otherwise, multiple downloads could be downloading to "FILE A", and "file a", although only "file a" exists on disk and is being written to by both.
 */
public synchronized File getFile(RemoteFileDesc rfd){
  File incDir=SharingSettings.INCOMPLETE_DIRECTORY.getValue();
  incDir.mkdirs();
  String convertedName=CommonUtils.convertFileName(rfd.getFileName());
  URN sha1=rfd.getSHA1Urn();
  if (sha1 != null) {
    File file=(File)hashes.get(sha1);
    if (file != null) {
      return file;
    }
 else {
      for (int i=1; ; i++) {
        file=new File(incDir,tempName(convertedName,rfd.getSize(),i));
        try {
          file=FileUtils.getCanonicalFile(file);
        }
 catch (        IOException ignored) {
        }
        if (!hashes.values().contains(file))         break;
      }
      hashes.put(sha1,file);
      return file;
    }
  }
 else {
    File f=new File(incDir,tempName(convertedName,rfd.getSize(),0));
    try {
      f=FileUtils.getCanonicalFile(f);
    }
 catch (    IOException ignored) {
    }
    return f;
  }
}

Fixed version (ground truth):
/** 
 * Returns the fully-qualified temporary download file for the given file/location pair.  The location of the file is determined by the INCOMPLETE_DIRECTORY property.  For example, getFile("test.txt", 1999) may return "C:\Program Files\LimeWire\Incomplete\T-1999-Test.txt".  The disk is not modified.<p> This method gives duplicate files the same temporary file, which is critical for resume and swarmed downloads.  That is, for all rfd_i and  rfd_j <pre> similar(rfd_i, rfd_j) <==> getFile(rfd_i).equals(getFile(rfd_j))<p>   </pre> It is imperative that the files are compared as in their canonical formats to preserve the integrity of the filesystem.  Otherwise, multiple downloads could be downloading to "FILE A", and "file a", although only "file a" exists on disk and is being written to by both.
 * @throws IOException if there was an IOError while determining thefile's name.
 */
public synchronized File getFile(RemoteFileDesc rfd) throws IOException {
  File incDir=SharingSettings.INCOMPLETE_DIRECTORY.getValue();
  incDir.mkdirs();
  String convertedName=CommonUtils.convertFileName(rfd.getFileName());
  URN sha1=rfd.getSHA1Urn();
  if (sha1 != null) {
    File file=(File)hashes.get(sha1);
    if (file != null) {
      return file;
    }
 else {
      for (int i=1; ; i++) {
        file=new File(incDir,tempName(convertedName,rfd.getSize(),i));
        file=FileUtils.getCanonicalFile(file);
        if (!hashes.values().contains(file))         break;
      }
      hashes.put(sha1,file);
      return file;
    }
  }
 else {
    File f=new File(incDir,tempName(convertedName,rfd.getSize(),0));
    f=FileUtils.getCanonicalFile(f);
    return f;
  }
}