From 94cd4acef867fa123b8d834592a7824c43ede492 Mon Sep 17 00:00:00 2001 From: Eric Wild Date: Thu, 31 Oct 2019 19:18:45 +0100 Subject: sim: allow opening reader# > 0 Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5 --- src/sim/reader_pcsc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sim') diff --git a/src/sim/reader_pcsc.c b/src/sim/reader_pcsc.c index f22103f4..9e05e3c0 100644 --- a/src/sim/reader_pcsc.c +++ b/src/sim/reader_pcsc.c @@ -79,17 +79,18 @@ static struct osim_reader_hdl *pcsc_reader_open(int num, const char *id, void *c rc = SCardListReaders(st->hContext, NULL, (LPSTR)&mszReaders, &dwReaders); PCSC_ERROR(rc, "SCardListReaders"); + /* SCARD_S_SUCCESS means there is at least one reader in the group */ num_readers = 0; ptr = mszReaders; - while (*ptr != '\0') { + while (*ptr != '\0' && num_readers != num) { ptr += strlen(ptr)+1; num_readers++; } - if (num_readers == 0) + if (num != num_readers) goto end; - st->name = talloc_strdup(rh, mszReaders); + st->name = talloc_strdup(rh, ptr); st->dwActiveProtocol = -1; return rh; -- cgit v1.2.3