From 524346901a4aeec05288f9640c5e427c3d63acd9 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 17 Apr 2019 14:48:32 +0200 Subject: [PATCH] test fixes --- client/emv/cmdemv.c | 2 +- client/emv/crypto_polarssl.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/emv/cmdemv.c b/client/emv/cmdemv.c index 879d53c92..041ad73ee 100644 --- a/client/emv/cmdemv.c +++ b/client/emv/cmdemv.c @@ -287,7 +287,7 @@ static int CmdEMVGPO(const char *Cmd) { PrintAndLogEx(ERR, "Can't create PDOL data."); tlvdb_free(tmp_ext); tlvdb_free(tlvRoot); - free(pdol_data_tlv); + free(data_tlv); return 4; } PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len)); diff --git a/client/emv/crypto_polarssl.c b/client/emv/crypto_polarssl.c index ff5a867a9..7882790d0 100644 --- a/client/emv/crypto_polarssl.c +++ b/client/emv/crypto_polarssl.c @@ -253,20 +253,29 @@ static size_t crypto_pk_polarssl_get_nbits(const struct crypto_pk *_cp) { static unsigned char *crypto_pk_polarssl_get_parameter(const struct crypto_pk *_cp, unsigned param, size_t *plen) { struct crypto_pk_polarssl *cp = (struct crypto_pk_polarssl *)_cp; unsigned char *result = NULL; + int res; switch (param) { // mod case 0: *plen = mbedtls_mpi_size(&cp->ctx.N); result = malloc(*plen); memset(result, 0x00, *plen); - mbedtls_mpi_write_binary(&cp->ctx.N, result, *plen); + res = mbedtls_mpi_write_binary(&cp->ctx.N, result, *plen); + if ( res == 0 ) { + printf("Error write_binary."); + result = 0; + } break; // exp case 1: *plen = mbedtls_mpi_size(&cp->ctx.E); result = malloc(*plen); memset(result, 0x00, *plen); - mbedtls_mpi_write_binary(&cp->ctx.E, result, *plen); + res = mbedtls_mpi_write_binary(&cp->ctx.E, result, *plen); + if ( res == 0 ) { + printf("Error write_binary."); + result = 0; + } break; default: printf("Error get parameter. Param = %u", param);