From 6eb7c8e7a5195464e64febb9251a0f4013029c76 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 4 Nov 2019 23:21:02 +0200 Subject: [PATCH] fixed aid selection --- client/aidsearch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/aidsearch.c b/client/aidsearch.c index 04aec92a5..54b970187 100644 --- a/client/aidsearch.c +++ b/client/aidsearch.c @@ -123,13 +123,17 @@ int PrintAIDDescription(char *aid, bool verbose) { goto out; json_t *elm = NULL; + int maxaidlen = 0; for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) { json_t *data = AIDSearchGetElm(root, elmindx); if (data == NULL) continue; - if (aidCompare(jsonStrGet(data, "AID"), aid)) { - elm = data; - break; + const char *dictaid = jsonStrGet(data, "AID"); + if (aidCompare(aid, dictaid)) { // dictaid may be less length than requested aid + if (maxaidlen < strlen(dictaid) && strlen(dictaid) <= strlen(aid)) { + maxaidlen = strlen(dictaid); + elm = data; + } } }