From a233d19691a221a356fcbccba13f6946232663d4 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Tue, 26 Oct 2010 13:47:23 +0000 Subject: [PATCH] - fixed memory corruption on card initialization - fixed compilation warning git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@340 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/ccid.c | 6 +++--- ccid/src/scutil.c | 4 ++-- ccid/src/usb.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ccid/src/ccid.c b/ccid/src/ccid.c index 0c03533..efd511a 100644 --- a/ccid/src/ccid.c +++ b/ccid/src/ccid.c @@ -137,9 +137,8 @@ int ccid_initialize(int reader_id, const char *cdriver, int verbose) { int i; - for (i = 0; i < sizeof *card_in_slot; i++) { + for (i = 0; i < sizeof(card_in_slot)/sizeof(*card_in_slot); i++) card_in_slot[i] = NULL; - } i = initialize(reader_id, cdriver, verbose, &ctx, &reader); if (i < 0) @@ -1153,7 +1152,8 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle sc_result = perform_PC_to_RDR_Secure_GetReadersPACECapabilities( &abDataOut, &abDataOutLen); - bin_log(card_in_slot[request->bSlot], "PACE Capabilities", abDataOut, abDataOutLen); + if (card_in_slot[request->bSlot]) + bin_log(card_in_slot[request->bSlot]->ctx, "PACE Capabilities", abDataOut, abDataOutLen); goto err; break; diff --git a/ccid/src/scutil.c b/ccid/src/scutil.c index d9be68e..ff5b173 100644 --- a/ccid/src/scutil.c +++ b/ccid/src/scutil.c @@ -56,12 +56,12 @@ int initialize(int reader_id, const char *cdriver, int verbose, *reader = sc_ctx_get_reader(*ctx, i); if (sc_detect_card_presence(*reader, 0) & SC_SLOT_CARD_PRESENT) { reader_id = i; - sc_debug(*ctx, "Using reader with a card: %s", (*reader)->name); + sc_debug(*ctx, "Using the first reader with a card: %s", (*reader)->name); break; } } if (reader_id >= reader_count) { - /* no reader found, use the first */ + sc_debug(*ctx, "No card found, using the first reader."); reader_id = 0; } } diff --git a/ccid/src/usb.c b/ccid/src/usb.c index 7788a63..5f61490 100644 --- a/ccid/src/usb.c +++ b/ccid/src/usb.c @@ -1814,9 +1814,6 @@ main (int argc, char **argv) return 1; } - if (verbose) - fprintf (stderr, "serial=\"%s\"\n", serial); - if (chdir (gadgetfs) < 0) { fprintf (stderr, "Error changing directory to %s\n", gadgetfs); return 1; @@ -1839,6 +1836,9 @@ main (int argc, char **argv) } } + if (verbose) + fprintf (stderr, "serial=\"%s\"\n", doserial ? doserial : serial); + if (doiintf) { for (i=0; i