From 5f54e4a7802bf1f8bc75c9b8928167f4c37a7054 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Tue, 12 Oct 2010 12:33:57 +0000 Subject: [PATCH] added inconsistency check for the received apdu git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@324 96b47cad-a561-4643-ad3b-153ac7d7599c --- virtualsmartcard/src/vpicc/VirtualSmartcard.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtualsmartcard/src/vpicc/VirtualSmartcard.py b/virtualsmartcard/src/vpicc/VirtualSmartcard.py index 1e3c19a..ffe3223 100644 --- a/virtualsmartcard/src/vpicc/VirtualSmartcard.py +++ b/virtualsmartcard/src/vpicc/VirtualSmartcard.py @@ -538,8 +538,11 @@ class VirtualICC(object): # {{{ # receive and return message if size: msg = self.sock.recv(size) + if len(msg) == 0: + print "Virtual PCD shut down" else: msg = None + return size, msg def run(self): @@ -562,6 +565,9 @@ class VirtualICC(object): # {{{ else: print "unknown control command" else: + if size != len(msg): + print "Expected APDU of %u bytes, but received only %u" % (size, len(msg)) + print "APDU (%d Bytes):\n%s" % (len(msg),hexdump(msg, short=True)) answer = self.os.execute(msg) print "RESP (%d Bytes):\n%s\n" % (len(answer),hexdump(answer, short=True))