// for the HISTORY op_code, determine how many transactions will be sent by transaction_list_send_last_n() // create a packet_data_history struct and send it with the count value equal to the number of // transactions that will be sent. // success: SUCCESS // failure: ERRNO_MP_NO_HISTORY int transaction_get_history_count_and_send(uint32_t card_id, list_t * tr_list, uint32_t max_tr_count) { if(0 == tr_list->count) {return ERRNO_MP_NO_HISTORY;} int tr_send_count = 0; node_t * curr = tr_list->tail->prev; while(curr != tr_list->head && (max_tr_count > tr_send_count)) { // curr->data is the pointer to the transaction entry; // get transaction transaction_t * tr = (transaction_t *)curr->data; // if this transaction matches card_id, count it if(card_id == tr->card_id) { // increment tr_send_count tr_send_count++; } // get next node curr = curr->prev; } // create and send the history details packet_data_history_t pdh; pdh.count = tr_send_count; // send history details transaction_send_history(&pdh); return SUCCESS; }
// send transaction details (call func based on op_code). // success: SUCCESS // failure: ERRNO_MP_INVALID_OPCODE int transaction_send_details(transaction_t * tr) { // get op_code to determine type of transaction switch(tr->op_code) { case PURCHASE : transaction_send_purchase(tr->details); break; case RECHARGE : transaction_send_recharge(tr->details); break; case BALANCE : transaction_send_balance(tr->details); break; case HISTORY : transaction_send_history(tr->details); break; case ISSUE : transaction_send_issue(tr->details); break; case REFUND : transaction_send_refund(tr->details); break; default : return ERRNO_MP_INVALID_OPCODE; } return SUCCESS; }
// send transaction details (call func based on op_code). // success: SUCCESS // failure: ERRNO_MP_INVALID_OPCODE int transaction_send_details(transaction_t * tr) { #ifdef PATCHED // VULNERABLE CODE: the transaction does not have details in the AUTH phase if (tr->state == AUTH) { return SUCCESS; } #endif // get op_code to determine type of transaction switch(tr->op_code) { case PURCHASE : transaction_send_purchase(tr->details); break; case RECHARGE : transaction_send_recharge(tr->details); break; case BALANCE : transaction_send_balance(tr->details); break; case HISTORY : transaction_send_history(tr->details); break; case ISSUE : transaction_send_issue(tr->details); break; case REFUND : transaction_send_refund(tr->details); break; default : return ERRNO_MP_INVALID_OPCODE; } return SUCCESS; }