diff --git a/ccid/src/Makefile.am b/ccid/src/Makefile.am index 1f715fc..f6ae0f8 100644 --- a/ccid/src/Makefile.am +++ b/ccid/src/Makefile.am @@ -24,6 +24,9 @@ noinst_HEADERS = \ ccid.h \ usbstring.h +flaw: + flawfinder -SQD *.h *.c + if WITH_CCID bin_PROGRAMS += ccid-emulator endif diff --git a/ccid/src/binutil.c b/ccid/src/binutil.c index b180d4e..91abd5a 100644 --- a/ccid/src/binutil.c +++ b/ccid/src/binutil.c @@ -19,7 +19,6 @@ #include "binutil.h" #include #include -#include void print_usage(const char *app_name, const struct option options[], const char *option_help[]) @@ -70,59 +69,3 @@ void parse_error(const char *app_name, const struct option options[], printf("Could not parse %s ('%s').\n", options[opt_ind].name, optarg); print_usage(app_name , options, option_help); } - -static int list_readers(sc_context_t *ctx) -{ - unsigned int i, rcount = sc_ctx_get_reader_count(ctx); - - if (rcount == 0) { - printf("No smart card readers found.\n"); - return 0; - } - printf("Readers known about:\n"); - printf("Nr. Driver Name\n"); - for (i = 0; i < rcount; i++) { - sc_reader_t *screader = sc_ctx_get_reader(ctx, i); - printf("%-7d%-11s%s\n", i, screader->driver->short_name, - screader->name); - } - - return 0; -} - -static int list_drivers(sc_context_t *ctx) -{ - int i; - - if (ctx->card_drivers[0] == NULL) { - printf("No card drivers installed!\n"); - return 0; - } - printf("Configured card drivers:\n"); - for (i = 0; ctx->card_drivers[i] != NULL; i++) { - printf(" %-16s %s\n", ctx->card_drivers[i]->short_name, - ctx->card_drivers[i]->name); - } - - return 0; -} - -int print_avail(int verbose) -{ - sc_context_t *ctx = NULL; - - int r; - r = sc_context_create(&ctx, NULL); - if (r) { - fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r)); - return 1; - } - ctx->debug = verbose; - - r = list_readers(ctx)|list_drivers(ctx); - - if (ctx) - sc_release_context(ctx); - - return r; -} diff --git a/ccid/src/binutil.h b/ccid/src/binutil.h index c38a270..6314dc3 100644 --- a/ccid/src/binutil.h +++ b/ccid/src/binutil.h @@ -26,6 +26,4 @@ void print_usage(const char *app_name, const struct option options[], void parse_error(const char *app_name, const struct option options[], const char *option_help[], const char *optarg, int opt_ind); -int print_avail(int verbose); - #endif diff --git a/ccid/src/pace/scutil.h b/ccid/src/pace/scutil.h index b01b34f..0082682 100644 --- a/ccid/src/pace/scutil.h +++ b/ccid/src/pace/scutil.h @@ -89,4 +89,6 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line, const char *func, const char *label, const u8 *data, size_t len, FILE *f); +int print_avail(int verbose); + #endif diff --git a/ccid/src/scutil.c b/ccid/src/scutil.c index 2fba000..d9be68e 100644 --- a/ccid/src/scutil.c +++ b/ccid/src/scutil.c @@ -212,3 +212,58 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line, } } +static int list_drivers(sc_context_t *ctx) +{ + int i; + + if (ctx->card_drivers[0] == NULL) { + printf("No card drivers installed!\n"); + return 0; + } + printf("Configured card drivers:\n"); + for (i = 0; ctx->card_drivers[i] != NULL; i++) { + printf(" %-16s %s\n", ctx->card_drivers[i]->short_name, + ctx->card_drivers[i]->name); + } + + return 0; +} + +static int list_readers(sc_context_t *ctx) +{ + unsigned int i, rcount = sc_ctx_get_reader_count(ctx); + + if (rcount == 0) { + printf("No smart card readers found.\n"); + return 0; + } + printf("Readers known about:\n"); + printf("Nr. Driver Name\n"); + for (i = 0; i < rcount; i++) { + sc_reader_t *screader = sc_ctx_get_reader(ctx, i); + printf("%-7d%-11s%s\n", i, screader->driver->short_name, + screader->name); + } + + return 0; +} + +int print_avail(int verbose) +{ + sc_context_t *ctx = NULL; + + int r; + r = sc_context_create(&ctx, NULL); + if (r) { + fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r)); + return 1; + } + ctx->debug = verbose; + + r = list_readers(ctx)|list_drivers(ctx); + + if (ctx) + sc_release_context(ctx); + + return r; +} diff --git a/ccid/src/usb.c b/ccid/src/usb.c index 7842f40..7788a63 100644 --- a/ccid/src/usb.c +++ b/ccid/src/usb.c @@ -293,6 +293,7 @@ static const struct usb_endpoint_descriptor *hs_eps [] = { /*-------------------------------------------------------------------------*/ /* 56 is the maximum for the KOBIL Class 3 Reader */ +/* Flawfinder: ignore */ static char serial [57]; static const char interrupt_on_string[] = "Insertion and removal events enabled";