[Pkg-gnupg-commit] [gnupg2] 21/185: scd: Handle a failure of libusb_init.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Aug 7 11:55:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 5c33649782bf255af5a55f16eac5e85f059b00bf
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Wed May 31 09:49:54 2017 +0900
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 at gmail.com>
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
---
scd/ccid-driver.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index fbbd157..1d5e8f2 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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list