From 837d952bb9eb15faf87368aa7ba6c46fb4989260 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Mon, 4 Oct 2010 13:54:58 +0000 Subject: [PATCH] using strtol instead of sscanf git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@296 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/ccid.h | 2 +- ccid/src/usb.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ccid/src/ccid.h b/ccid/src/ccid.h index c628111..69b7772 100644 --- a/ccid/src/ccid.h +++ b/ccid/src/ccid.h @@ -274,7 +274,7 @@ struct hid_class_descriptor { /** * @brief Initializes reader for relaying * - * @param[in] reader_id (optional) Index to the reader to be used. Set to -1 to use a reader with a inserted card. + * @param[in] reader_id (optional) Index to the reader to be used. Set to -1 to use the first reader with a card or the first reader if no card is available. * @param[in] cdriver (optional) Card driver to be used * @param[in] verbose Verbosity level passed to \c sc_context_t * diff --git a/ccid/src/usb.c b/ccid/src/usb.c index 18d90f3..777643c 100644 --- a/ccid/src/usb.c +++ b/ccid/src/usb.c @@ -1736,7 +1736,9 @@ main (int argc, char **argv) exit(0); break; case OPT_READER: - if (sscanf(optarg, "%d", &usb_reader_num) != 1) { + errno = 0; + usb_reader_num = strtol(optarg, NULL, 10); + if (errno) { parse_error(argv[0], options, option_help, optarg, oindex); exit(2); } @@ -1748,13 +1750,17 @@ main (int argc, char **argv) doiintf = optarg; break; case OPT_PRODUCT: - if (sscanf(optarg, "%x", &productid) != 1) { + errno = 0; + productid = strtol(optarg, NULL, 16); + if (errno) { parse_error(argv[0], options, option_help, optarg, oindex); exit(2); } break; case OPT_VENDOR: - if (sscanf(optarg, "%x", &vendorid) != 1) { + errno = 0; + vendorid = strtol(optarg, NULL, 16); + if (errno) { parse_error(argv[0], options, option_help, optarg, oindex); exit(2); }