Program: 170782
Project: 170782
Buggy source:
private boolean authenticateSupport(String headers,URL resource,String user,String pw){
  boolean result;
  boolean auto_auth=param_auto_auth != null && param_auto_auth.getValue();
  if (!pw_enable.getValue()) {
    String whitelist=p_no_pw_whitelist.getValue().trim();
    if (whitelist.equals("String_Node_Str")) {
      result=true;
    }
 else {
      String actual_host=getHeaderField(headers,"String_Node_Str");
      int actual_port=protocol == Tracker.PR_HTTP ? 80 : 443;
      String referrer=getHeaderField(headers,"String_Node_Str");
      if (actual_host.startsWith("String_Node_Str")) {
        int pos=actual_host.lastIndexOf(']');
        if (pos != -1) {
          String rem=actual_host.substring(pos + 1);
          actual_host=actual_host.substring(0,pos + 1);
          pos=rem.indexOf(':');
          if (pos != -1) {
            actual_port=Integer.parseInt(rem.substring(pos + 1).trim());
          }
        }
      }
 else {
        int pos=actual_host.indexOf(':');
        if (pos != -1) {
          actual_port=Integer.parseInt(actual_host.substring(pos + 1).trim());
          actual_host=actual_host.substring(0,pos);
        }
      }
      String[] allowed=whitelist.split("String_Node_Str");
      result=false;
      String msg="String_Node_Str";
      if (actual_port != port) {
        msg="String_Node_Str" + port + "String_Node_Str"+ actual_port;
      }
 else {
        for (        String a : allowed) {
          a=a.trim();
          if (a.equals("String_Node_Str")) {
            InetAddress bind=getServerBindIP();
            if (bind != null) {
              if (bind instanceof Inet6Address) {
                a="String_Node_Str" + bind.getHostAddress() + "String_Node_Str";
              }
 else {
                a=bind.getHostAddress();
              }
            }
          }
          if (actual_host.equals(a.trim())) {
            result=true;
            break;
          }
        }
        if (!result) {
          msg="String_Node_Str" + actual_host + "String_Node_Str";
        }
 else {
          if (referrer != null) {
            result=false;
            try {
              URL url=new URL(referrer);
              int ref_port=url.getPort();
              if (ref_port == -1) {
                ref_port=url.getDefaultPort();
              }
              if (ref_port == port) {
                result=true;
              }
            }
 catch (            Throwable e) {
            }
            if (!result) {
              msg="String_Node_Str" + referrer;
            }
          }
        }
      }
      if (!result) {
        log.log("String_Node_Str" + msg);
      }
    }
  }
 else {
    if (auto_auth) {
      user=user.trim().toLowerCase();
      pw=pw.toUpperCase();
    }
    if (!user.equals(p_user_name.getValue())) {
      result=false;
    }
 else {
      byte[] hash=last_hash;
      if (!last_pw.equals(pw)) {
        hash=plugin_interface.getUtilities().getSecurityManager().calculateSHA1(auto_auth ? pw.toUpperCase().getBytes() : pw.getBytes());
        last_pw=pw;
        last_hash=hash;
      }
      result=Arrays.equals(hash,p_password.getValue());
    }
  }
  if (result) {
    checkCookieSet(headers,resource);
  }
 else   if (auto_auth) {
    int x=checkCookieSet(headers,resource);
    if (x == 1) {
      result=true;
    }
 else     if (x == 0) {
      result=hasOurCookie(getHeaderField(headers,"String_Node_Str"));
    }
  }
 else {
    result=hasOurCookie(getHeaderField(headers,"String_Node_Str"));
  }
  return (result);
}

Fixed version (ground truth):
private boolean authenticateSupport(String headers,URL resource,String user,String pw){
  boolean result;
  boolean auto_auth=param_auto_auth != null && param_auto_auth.getValue();
  if (!pw_enable.getValue()) {
    String whitelist=p_no_pw_whitelist.getValue().trim();
    if (whitelist.equals("String_Node_Str")) {
      result=true;
    }
 else {
      String actual_host=getHeaderField(headers,"String_Node_Str");
      int actual_port=protocol == Tracker.PR_HTTP ? 80 : 443;
      String referrer=getHeaderField(headers,"String_Node_Str");
      if (actual_host.startsWith("String_Node_Str")) {
        int pos=actual_host.lastIndexOf(']');
        if (pos != -1) {
          String rem=actual_host.substring(pos + 1);
          actual_host=actual_host.substring(0,pos + 1);
          pos=rem.indexOf(':');
          if (pos != -1) {
            actual_port=Integer.parseInt(rem.substring(pos + 1).trim());
          }
        }
      }
 else {
        int pos=actual_host.indexOf(':');
        if (pos != -1) {
          actual_port=Integer.parseInt(actual_host.substring(pos + 1).trim());
          actual_host=actual_host.substring(0,pos);
        }
      }
      String[] allowed=whitelist.split("String_Node_Str");
      result=false;
      String msg="String_Node_Str";
      if (actual_port != port) {
        msg="String_Node_Str" + port + "String_Node_Str"+ actual_port;
      }
 else {
        for (        String a : allowed) {
          a=a.trim();
          if (a.equals("String_Node_Str")) {
            InetAddress bind=getServerBindIP();
            if (bind != null) {
              if (bind instanceof Inet6Address) {
                a="String_Node_Str" + bind.getHostAddress() + "String_Node_Str";
              }
 else {
                a=bind.getHostAddress();
              }
            }
          }
          if (actual_host.equals(a.trim())) {
            result=true;
            break;
          }
        }
        if (!result) {
          msg="String_Node_Str" + actual_host + "String_Node_Str";
        }
 else {
          if (referrer != null) {
            result=false;
            try {
              URL url=new URL(referrer);
              int ref_port=url.getPort();
              if (ref_port == -1) {
                ref_port=url.getDefaultPort();
              }
              if (ref_port == port) {
                result=true;
              }
            }
 catch (            Throwable e) {
            }
            if (!result) {
              msg="String_Node_Str" + referrer;
            }
          }
        }
      }
      if (!result) {
        log.log("String_Node_Str" + msg);
      }
    }
  }
 else {
    if (auto_auth) {
      user=user.trim().toLowerCase();
      pw=pw.toUpperCase();
    }
    if (!user.equals(p_user_name.getValue())) {
      log.log("String_Node_Str" + user);
      result=false;
    }
 else {
      byte[] hash=last_hash;
      if (!last_pw.equals(pw)) {
        hash=plugin_interface.getUtilities().getSecurityManager().calculateSHA1(auto_auth ? pw.toUpperCase().getBytes() : pw.getBytes());
        last_pw=pw;
        last_hash=hash;
      }
      result=Arrays.equals(hash,p_password.getValue());
      if (!result) {
        log.log("String_Node_Str");
      }
    }
  }
  if (result) {
    checkCookieSet(headers,resource);
  }
 else   if (auto_auth) {
    int x=checkCookieSet(headers,resource);
    if (x == 1) {
      result=true;
    }
 else     if (x == 0) {
      result=hasOurCookie(getHeaderField(headers,"String_Node_Str"));
    }
  }
 else {
    result=hasOurCookie(getHeaderField(headers,"String_Node_Str"));
  }
  return (result);
}