Files
macports-ports/security/opensc/files/patch-pgp-and-tools.diff

134 lines
3.7 KiB
Diff

#
# Changes are taken from OpenSC master branch, most probably this patch
# will not be needed after next release.
#
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index fad32f0c..e4e6cc4d 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -129,7 +129,7 @@ static pgp_ec_curves_t ec_curves_gnuk[] = {
static int pgp_get_card_features(sc_card_t *card);
static int pgp_finish(sc_card_t *card);
-static void pgp_iterate_blobs(pgp_blob_t *, void (*func)());
+static void pgp_free_blobs(pgp_blob_t *);
static int pgp_get_blob(sc_card_t *card, pgp_blob_t *blob,
unsigned int id, pgp_blob_t **ret);
@@ -947,7 +947,7 @@ pgp_finish(sc_card_t *card)
if (priv != NULL) {
/* delete fake file hierarchy */
- pgp_iterate_blobs(priv->mf, pgp_free_blob);
+ pgp_free_blobs(priv->mf);
/* delete private data */
free(priv);
@@ -1147,10 +1147,10 @@ pgp_free_blob(pgp_blob_t *blob)
/**
- * Internal: iterate through the blob tree, calling a function for each blob.
+ * Internal: iterate through the blob tree, calling pgp_free_blob for each blob.
*/
static void
-pgp_iterate_blobs(pgp_blob_t *blob, void (*func)())
+pgp_free_blobs(pgp_blob_t *blob)
{
if (blob) {
pgp_blob_t *child = blob->files;
@@ -1158,10 +1158,10 @@ pgp_iterate_blobs(pgp_blob_t *blob, void (*func)())
while (child != NULL) {
pgp_blob_t *next = child->next;
- pgp_iterate_blobs(child, func);
+ pgp_free_blobs(child);
child = next;
}
- func(blob);
+ pgp_free_blob(blob);
}
}
diff --git a/src/tools/cardos-tool.c b/src/tools/cardos-tool.c
index 4e6dd554..26959abb 100644
--- a/src/tools/cardos-tool.c
+++ b/src/tools/cardos-tool.c
@@ -1183,6 +1183,9 @@ int main(int argc, char *argv[])
}
}
+ if (action_count == 0)
+ util_print_usage_and_die(app_name, options, option_help, NULL);
+
/* create sc_context_t object */
memset(&ctx_param, 0, sizeof(ctx_param));
ctx_param.ver = 0;
diff --git a/src/tools/netkey-tool.c b/src/tools/netkey-tool.c
index f2904ad1..ad82b282 100644
--- a/src/tools/netkey-tool.c
+++ b/src/tools/netkey-tool.c
@@ -535,6 +535,7 @@ int main(
fprintf(stderr,"Establish-Context failed: %s\n", sc_strerror(r));
exit(1);
}
+ ctx->debug = debug;
if(ctx->debug>0)
printf("Context for application \"%s\" created, Debug=%d\n", ctx->app_name, ctx->debug);
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index aae205fe..8402fe39 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -7315,41 +7315,42 @@ static int test_random(CK_SESSION_HANDLE session)
printf(" seeding (C_SeedRandom) not supported\n");
else if (rv != CKR_OK) {
p11_perror("C_SeedRandom", rv);
- return 1;
+ errors++;
}
rv = p11->C_GenerateRandom(session, buf1, 10);
if (rv != CKR_OK) {
p11_perror("C_GenerateRandom", rv);
- return 1;
+ errors++;
}
rv = p11->C_GenerateRandom(session, buf1, 100);
if (rv != CKR_OK) {
p11_perror("C_GenerateRandom(buf1,100)", rv);
- return 1;
+ errors++;
}
rv = p11->C_GenerateRandom(session, buf1, 0);
if (rv != CKR_OK) {
p11_perror("C_GenerateRandom(buf1,0)", rv);
- return 1;
+ errors++;
}
rv = p11->C_GenerateRandom(session, buf2, 100);
if (rv != CKR_OK) {
p11_perror("C_GenerateRandom(buf2,100)", rv);
- return 1;
+ errors++;
}
if (memcmp(buf1, buf2, 100) == 0) {
printf(" ERR: C_GenerateRandom returned twice the same value!!!\n");
- errors++;
+ errors++;
}
- printf(" seems to be OK\n");
+ if (!errors)
+ printf(" seems to be OK\n");
- return 0;
+ return errors;
}
static int test_card_detection(int wait_for_event)