Program: 20115
Project: 20115
Buggy source:
/** 
 * Method used to construct value from tag and length
 * @param pTagAndLength tag and length value
 * @return tag value in byte
 */
public static byte[] constructValue(final TagAndLength pTagAndLength){
  byte ret[]=new byte[pTagAndLength.getLength()];
  byte val[]=null;
  if (pTagAndLength.getTag() == EmvTags.TERMINAL_TRANSACTION_QUALIFIERS) {
    TerminalTransactionQualifiers terminalQual=new TerminalTransactionQualifiers();
    terminalQual.setContactlessEMVmodeSupported(true);
    ret=terminalQual.getBytes();
  }
 else   if (pTagAndLength.getTag() == EmvTags.TERMINAL_COUNTRY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CountryCodeEnum.FR.getNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_CURRENCY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CurrencyEnum.EUR.getISOCodeNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_DATE) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    val=BytesUtils.fromString(sdf.format(new Date()));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_TYPE) {
    val=new byte[]{(byte)TransactionTypeEnum.PURCHASE.getKey()};
  }
 else   if (pTagAndLength.getTag() == EmvTags.AMOUNT_AUTHORISED_NUMERIC) {
    val=BytesUtils.fromString("String_Node_Str");
  }
 else   if (pTagAndLength.getTag() == EmvTags.UNPREDICTABLE_NUMBER) {
    random.nextBytes(ret);
  }
  if (val != null) {
    System.arraycopy(val,Math.max(0,val.length - ret.length),ret,Math.max(ret.length - val.length,0),Math.min(val.length,ret.length));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to construct value from tag and length
 * @param pTagAndLength tag and length value
 * @return tag value in byte
 */
public static byte[] constructValue(final TagAndLength pTagAndLength){
  byte ret[]=new byte[pTagAndLength.getLength()];
  byte val[]=null;
  if (pTagAndLength.getTag() == EmvTags.TERMINAL_TRANSACTION_QUALIFIERS) {
    TerminalTransactionQualifiers terminalQual=new TerminalTransactionQualifiers();
    terminalQual.setContactlessEMVmodeSupported(true);
    terminalQual.setReaderIsOfflineOnly(true);
    ret=terminalQual.getBytes();
  }
 else   if (pTagAndLength.getTag() == EmvTags.TERMINAL_COUNTRY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CountryCodeEnum.FR.getNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_CURRENCY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CurrencyEnum.EUR.getISOCodeNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_DATE) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    val=BytesUtils.fromString(sdf.format(new Date()));
  }
 else   if (pTagAndLength.getTag() == EmvTags.TRANSACTION_TYPE) {
    val=new byte[]{(byte)TransactionTypeEnum.PURCHASE.getKey()};
  }
 else   if (pTagAndLength.getTag() == EmvTags.AMOUNT_AUTHORISED_NUMERIC) {
    val=BytesUtils.fromString("String_Node_Str");
  }
 else   if (pTagAndLength.getTag() == EmvTags.UNPREDICTABLE_NUMBER) {
    random.nextBytes(ret);
  }
  if (val != null) {
    System.arraycopy(val,Math.max(0,val.length - ret.length),ret,Math.max(ret.length - val.length,0),Math.min(val.length,ret.length));
  }
  return ret;
}