Index: cackey.c ================================================================== --- cackey.c +++ cackey.c @@ -4895,10 +4895,17 @@ cackey_pcsc_connect(); CACKEY_DEBUG_PRINTF("Trying SCardListReaders() again"); scard_listreaders_ret = SCardListReaders(*cackey_pcsc_handle, NULL, NULL, &pcsc_readers_len); } + + if (scard_listreaders_ret == SCARD_E_INSUFFICIENT_BUFFER) { + CACKEY_DEBUG_PRINTF("Error. SCardListReaders() returned SCARD_E_INSUFFICIENT_BUFFER, assuming this is a bug (e.g., Google PCSC) and allocating a massive amount of space to hold the reader list."); + + pcsc_readers_len = 32768; + scard_listreaders_ret = SCARD_S_SUCCESS; + } if (scard_listreaders_ret == SCARD_S_SUCCESS && pcsc_readers_len != 0) { pcsc_readers = malloc(pcsc_readers_len); pcsc_readers_s = pcsc_readers;