[Pcsclite-cvs-commit] Drivers/ccid/src/towitoko pps.c,1.6,1.7

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/Drivers/ccid/src/towitoko
In directory haydn:/tmp/cvs-serv11170

Modified Files:
	pps.c 
Log Message:
PPS_Match() was wrong when the confirmation is shorter than the request


Index: pps.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/towitoko/pps.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pps.c	30 Jun 2004 14:02:54 -0000	1.6
+++ pps.c	30 Jun 2004 14:05:38 -0000	1.7
@@ -88,13 +88,16 @@
 PPS_Match (BYTE * request, unsigned len_request, BYTE * confirm, unsigned len_confirm)
 {
   /* See if the reply differs from request */
-  if ((len_request != len_confirm) ||
-      (!memcmp (request, confirm, len_request)))
-    {
-      /* See if the card specifies other than default FI and D */
-      if ((PPS_HAS_PPS1 (confirm)) && (confirm[2] != request[2]))
+  if ((len_request == len_confirm) &&	/* same length */
+      memcmp (request, confirm, len_request))	/* different contents */
 	return FALSE;
-    }
+
+  if (len_request < len_confirm)	/* confirm longer than request */
+    return FALSE;
+
+  /* See if the card specifies other than default FI and D */
+  if ((PPS_HAS_PPS1 (confirm)) && (confirm[2] != request[2]))
+    return FALSE;
 
   return TRUE;
 }
@@ -128,3 +131,4 @@
 
   return pck;
 }
+