Program: 21362
Project: 21362
Buggy source:
public PluginStep doFreeStep(PluginStep step,DownloadLink downloadLink) throws Exception {
switch (step.getStep()) {
case PluginStep.STEP_WAIT_TIME:
    Form[] forms=Form.getForms(downloadLink.getDownloadURL());
  if (forms.length < 2) {
    step.setStatus(PluginStep.STATUS_ERROR);
    logger.severe("String_Node_Str");
    downloadLink.setStatus(DownloadLink.STATUS_ERROR_FILE_NOT_FOUND);
    return null;
  }
form=forms[1];
form.remove("String_Node_Str");
form.put("String_Node_Str","String_Node_Str");
requestInfo=form.getRequestInfo();
return step;
case PluginStep.STEP_PENDING:
if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
return step;
}
try {
waittime=Long.parseLong(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch()) * 1000;
}
 catch (Exception e) {
try {
waittime=Long.parseLong(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch()) * 60000;
downloadLink.setStatus(DownloadLink.STATUS_ERROR_DOWNLOAD_LIMIT);
step.setStatus(PluginStep.STATUS_ERROR);
}
 catch (Exception es) {
step.setStatus(PluginStep.STATUS_ERROR);
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
return null;
}
}
step.setParameter((long)waittime);
return step;
case PluginStep.STEP_GET_CAPTCHA_FILE:
String ticketCode=JDUtilities.htmlDecode(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch());
RequestInfo req=new RequestInfo(ticketCode,null,requestInfo.getCookie(),requestInfo.getHeaders(),requestInfo.getResponseCode());
req.setConnection(requestInfo.getConnection());
form=Form.getForms(req)[0];
captchaFile=getLocalCaptchaFile(this,"String_Node_Str");
String captchaAdress=new Regexp(ticketCode,"String_Node_Str").getFirstMatch();
logger.info("String_Node_Str" + captchaAdress);
boolean fileDownloaded=JDUtilities.download(captchaFile,getRequestWithoutHtmlCode(new URL(captchaAdress),requestInfo.getCookie(),null,true).getConnection());
if (!fileDownloaded || !captchaFile.exists() || captchaFile.length() == 0) {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_IMAGEERROR);
step.setStatus(PluginStep.STATUS_ERROR);
return step;
}
try {
code=Plugin.getCaptchaCode(captchaFile,this);
}
 catch (Exception e) {
}
if (code == null || code == "String_Node_Str") {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_BOT_DETECTED);
step.setStatus(PluginStep.STATUS_ERROR);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str",false);
return step;
}
form.put("String_Node_Str",code);
step=nextStep(step);
case PluginStep.STEP_DOWNLOAD:
if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
return step;
}
URLConnection urlConnection=form.getConnection();
downloadLink.setName(getFileNameFormHeader(urlConnection));
downloadLink.setDownloadMax(urlConnection.getContentLength());
if (!hasEnoughHDSpace(downloadLink)) {
downloadLink.setStatus(DownloadLink.STATUS_ERROR_NO_FREE_SPACE);
step.setStatus(PluginStep.STATUS_ERROR);
return step;
}
int errorid;
if ((errorid=download(downloadLink,urlConnection)) == DOWNLOAD_SUCCESS) {
step.setStatus(PluginStep.STATUS_DONE);
downloadLink.setStatus(DownloadLink.STATUS_DONE);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str" + code,true);
return null;
}
 else if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
}
 else {
if (errorid != DOWNLOAD_ERROR_DOWNLOAD_INCOMPLETE && errorid != DOWNLOAD_ERROR_INVALID_OUTPUTFILE && errorid != DOWNLOAD_ERROR_OUTPUTFILE_ALREADYEXISTS && errorid != DOWNLOAD_ERROR_RENAME_FAILED && errorid != DOWNLOAD_ERROR_SECURITY) {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str" + code,false);
}
step.setStatus(PluginStep.STATUS_ERROR);
}
}
return step;
}

Fixed version (ground truth):
public PluginStep doFreeStep(PluginStep step,DownloadLink downloadLink) throws Exception {
switch (step.getStep()) {
case PluginStep.STEP_WAIT_TIME:
    Form[] forms=Form.getForms(downloadLink.getDownloadURL());
  if (forms.length < 2) {
    step.setStatus(PluginStep.STATUS_ERROR);
    logger.severe("String_Node_Str");
    downloadLink.setStatus(DownloadLink.STATUS_ERROR_FILE_NOT_FOUND);
    return null;
  }
form=forms[1];
form.remove("String_Node_Str");
form.put("String_Node_Str","String_Node_Str");
requestInfo=form.getRequestInfo();
return step;
case PluginStep.STEP_PENDING:
if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
return step;
}
try {
waittime=Long.parseLong(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch()) * 1000;
}
 catch (Exception e) {
try {
waittime=Long.parseLong(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch()) * 60000;
downloadLink.setStatus(DownloadLink.STATUS_ERROR_DOWNLOAD_LIMIT);
step.setStatus(PluginStep.STATUS_ERROR);
}
 catch (Exception es) {
step.setStatus(PluginStep.STATUS_ERROR);
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
return null;
}
}
step.setParameter((long)waittime);
return step;
case PluginStep.STEP_GET_CAPTCHA_FILE:
String ticketCode=JDUtilities.htmlDecode(new Regexp(requestInfo.getHtmlCode(),"String_Node_Str").getFirstMatch());
RequestInfo req=new RequestInfo(ticketCode,null,requestInfo.getCookie(),requestInfo.getHeaders(),requestInfo.getResponseCode());
req.setConnection(requestInfo.getConnection());
form=Form.getForms(req)[0];
captchaFile=getLocalCaptchaFile(this,"String_Node_Str");
String captchaAdress=new Regexp(ticketCode,"String_Node_Str").getFirstMatch();
logger.info("String_Node_Str" + captchaAdress);
boolean fileDownloaded=JDUtilities.download(captchaFile,getRequestWithoutHtmlCode(new URL(captchaAdress),requestInfo.getCookie(),null,true).getConnection());
if (!fileDownloaded || !captchaFile.exists() || captchaFile.length() == 0) {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_IMAGEERROR);
step.setStatus(PluginStep.STATUS_ERROR);
return step;
}
try {
code=Plugin.getCaptchaCode(captchaFile,this);
}
 catch (Exception e) {
}
if (code == null || code == "String_Node_Str") {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_BOT_DETECTED);
step.setStatus(PluginStep.STATUS_ERROR);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str",false);
return step;
}
form.put("String_Node_Str",code);
step.setStatus(PluginStep.STATUS_SKIP);
return step;
case PluginStep.STEP_DOWNLOAD:
if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
return step;
}
URLConnection urlConnection=form.getConnection();
downloadLink.setName(getFileNameFormHeader(urlConnection));
downloadLink.setDownloadMax(urlConnection.getContentLength());
if (!hasEnoughHDSpace(downloadLink)) {
downloadLink.setStatus(DownloadLink.STATUS_ERROR_NO_FREE_SPACE);
step.setStatus(PluginStep.STATUS_ERROR);
return step;
}
int errorid;
if ((errorid=download(downloadLink,urlConnection)) == DOWNLOAD_SUCCESS) {
step.setStatus(PluginStep.STATUS_DONE);
downloadLink.setStatus(DownloadLink.STATUS_DONE);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str" + code,true);
return null;
}
 else if (aborted) {
logger.warning("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_TODO);
step.setStatus(PluginStep.STATUS_TODO);
}
 else {
if (errorid != DOWNLOAD_ERROR_DOWNLOAD_INCOMPLETE && errorid != DOWNLOAD_ERROR_INVALID_OUTPUTFILE && errorid != DOWNLOAD_ERROR_OUTPUTFILE_ALREADYEXISTS && errorid != DOWNLOAD_ERROR_RENAME_FAILED && errorid != DOWNLOAD_ERROR_SECURITY) {
logger.severe("String_Node_Str");
downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
JDUtilities.appendInfoToFilename(captchaFile,"String_Node_Str" + code,false);
}
step.setStatus(PluginStep.STATUS_ERROR);
}
}
return step;
}