From 5cd5728c0e7b290b19e877689432ec87fca2efa4 Mon Sep 17 00:00:00 2001 From: "viktor.tarasov" Date: Tue, 26 Jan 2010 12:59:08 +0000 Subject: [PATCH] libopensc: search pkcs15 objects: accept NULL value for the output argument So that, the dummy object for the 'search pkcs15 object' calls is not neccessary. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3942 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/pkcs15.c | 2 +- src/pkcs15init/pkcs15-lib.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 0ee61595..c1bf1bb6 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -894,7 +894,7 @@ __sc_pkcs15_search_objects(sc_pkcs15_card_t *p15card, continue; /* Okay, we have a match. */ match_count++; - if (ret_size <= 0) + if (!ret || ret_size <= 0) continue; ret[match_count-1] = obj; if (ret_size <= match_count) diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index fa02dbc1..b1452670 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -961,14 +961,12 @@ sc_pkcs15init_store_pin(struct sc_pkcs15_card *p15card, /* No auth_id given: select one */ if (args->auth_id.len == 0) { - struct sc_pkcs15_object *dummy; unsigned int n; args->auth_id.len = 1; for (n = 1, r = 0; n < 256; n++) { args->auth_id.value[0] = n; - r = sc_pkcs15_find_pin_by_auth_id(p15card, - &args->auth_id, &dummy); + r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, NULL); if (r == SC_ERROR_OBJECT_NOT_FOUND) break; } @@ -977,10 +975,8 @@ sc_pkcs15init_store_pin(struct sc_pkcs15_card *p15card, return SC_ERROR_INVALID_ARGUMENTS; } } else { - struct sc_pkcs15_object *dummy; - /* Make sure we don't get duplicate PIN IDs */ - r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, &dummy); + r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, NULL); if (r != SC_ERROR_OBJECT_NOT_FOUND) { sc_debug(card->ctx, "There already is a PIN with this ID."); return SC_ERROR_INVALID_ARGUMENTS;