diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2017-05-31 02:49:54 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2017-05-31 02:49:54 +0200 |
commit | 5c33649782bf255af5a55f16eac5e85f059b00bf (patch) | |
tree | fa919e927dc70614ee9a4f9cfe5a9eededcf0672 /scd | |
parent | gpg: Fix typos. (diff) | |
download | gnupg2-5c33649782bf255af5a55f16eac5e85f059b00bf.tar.xz gnupg2-5c33649782bf255af5a55f16eac5e85f059b00bf.zip |
scd: Handle a failure of libusb_init.
* scd/ccid-driver.c (ccid_get_reader_list, ccid_dev_scan): Handle
failure.
--
Reported-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r-- | scd/ccid-driver.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c index fbbd1578d..1d5e8f26d 100644 --- a/scd/ccid-driver.c +++ b/scd/ccid-driver.c @@ -1228,7 +1228,12 @@ ccid_get_reader_list (void) if (!initialized_usb) { - libusb_init (NULL); + int rc; + if ((rc = libusb_init (NULL))) + { + DEBUGOUT_1 ("usb_init failed: %s.\n", libusb_error_name (rc)); + return NULL; + } initialized_usb = 1; } @@ -1292,9 +1297,17 @@ ccid_dev_scan (int *idx_max_p, struct ccid_dev_table **t_p) int idx = 0; int err = 0; + *idx_max_p = 0; + *t_p = NULL; + if (!initialized_usb) { - libusb_init (NULL); + int rc; + if ((rc = libusb_init (NULL))) + { + DEBUGOUT_1 ("usb_init failed: %s.\n", libusb_error_name (rc)); + return gpg_error (GPG_ERR_NOT_FOUND); + } initialized_usb = 1; } @@ -1373,8 +1386,6 @@ ccid_dev_scan (int *idx_max_p, struct ccid_dev_table **t_p) if (err) { - *idx_max_p = 0; - *t_p = NULL; for (i = 0; i < idx; i++) { free (ccid_dev_table[idx].ifcdesc_extra); |