opensc-explorer: detect AID conversion errors in arg_to_path()

Convert arg_to_path() to using the standard sc_hex_to_binary() instead of
the local hex2binary().
While at it, return erros on failed conversions.

Signed-off-by: Peter Marschall <peter@adpm.de>
This commit is contained in:
Peter Marschall 2011-06-02 16:13:04 +02:00
parent c3ba355531
commit 4cc1ab41ff
1 changed files with 7 additions and 1 deletions

View File

@ -276,8 +276,14 @@ static int arg_to_path(const char *arg, sc_path_t *path, int is_id)
if (strncasecmp(arg, "aid:", strlen("aid:")) == 0) {
/* DF aid */
const char *p = arg + strlen("aid:");
path->len = hex2binary(path->value, sizeof(path->value), p);
int r;
path->type = SC_PATH_TYPE_DF_NAME;
path->len = sizeof(path->value);
if ((r = sc_hex_to_bin(p, path->value, &path->len)) < 0) {
printf("Error parsing AID: %s\n", p);
return r;
}
} else {
/* file id */
unsigned int buf[2];