Change in pysim[master]: transport/pcsc: Raise exception if reader number is out of range

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sat May 22 07:33:11 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/24333 )


Change subject: transport/pcsc: Raise exception if reader number is out of range
......................................................................

transport/pcsc: Raise exception if reader number is out of range

Change-Id: I0acd6900feabb1cfa03b84f24903c6b746a6bdea
---
M pySim/transport/pcsc.py
1 file changed, 4 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/33/24333/1

diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py
index 73a99e8..c16abac 100644
--- a/pySim/transport/pcsc.py
+++ b/pySim/transport/pcsc.py
@@ -19,10 +19,10 @@
 
 from smartcard.CardConnection import CardConnection
 from smartcard.CardRequest import CardRequest
-from smartcard.Exceptions import NoCardException, CardRequestTimeoutException, CardConnectionException
+from smartcard.Exceptions import NoCardException, CardRequestTimeoutException, CardConnectionException, CardConnectionException
 from smartcard.System import readers
 
-from pySim.exceptions import NoCardError, ProtocolError
+from pySim.exceptions import NoCardError, ProtocolError, ReaderError
 from pySim.transport import LinkBase
 from pySim.utils import h2i, i2h
 
@@ -33,6 +33,8 @@
 	def __init__(self, reader_number:int=0, **kwargs):
 		super().__init__(**kwargs)
 		r = readers()
+		if reader_number >= len(r):
+			raise ReaderError
 		self._reader = r[reader_number]
 		self._con = self._reader.createConnection()
 

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/24333
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0acd6900feabb1cfa03b84f24903c6b746a6bdea
Gerrit-Change-Number: 24333
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210522/77354234/attachment.htm>


More information about the gerrit-log mailing list