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
This commit is contained in:
viktor.tarasov 2010-01-26 12:59:08 +00:00
parent 2ec8932c93
commit 5cd5728c0e
2 changed files with 3 additions and 7 deletions

View File

@ -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)

View File

@ -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;