From 7d4ba60e8e1b169822ff64a870b9f976585cb97c Mon Sep 17 00:00:00 2001 From: merlokk Date: Tue, 11 Sep 2018 14:56:33 +0300 Subject: [PATCH] `hf emv select` some refactoring --- client/cliparser/cliparser.c | 4 ++++ client/emv/cmdemv.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/cliparser/cliparser.c b/client/cliparser/cliparser.c index 0e70a630..87427db0 100644 --- a/client/cliparser/cliparser.c +++ b/client/cliparser/cliparser.c @@ -148,6 +148,10 @@ void CLIParserFree() { // convertors int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int *datalen) { + *datalen = 0; + if (!strlen(argstr->sval[0])) + return 0; + switch(param_gethex_to_eol(argstr->sval[0], 0, data, maxdatalen, datalen)) { case 1: printf("Parameter error: Invalid HEX value.\n"); diff --git a/client/emv/cmdemv.c b/client/emv/cmdemv.c index c40a9a69..33a519b1 100644 --- a/client/emv/cmdemv.c +++ b/client/emv/cmdemv.c @@ -51,8 +51,7 @@ int CmdHFEMVSelect(const char *cmd) { bool leaveSignalON = arg_get_lit(2); bool APDULogging = arg_get_lit(3); bool decodeTLV = arg_get_lit(4); - if (arg_get_str_len(5)) - CLIGetStrBLessWithReturn(5, data, &datalen, 0); + CLIGetStrBLessWithReturn(5, data, &datalen, 0); CLIParserFree(); SetAPDULogging(APDULogging); -- 2.39.5