[Pcsclite-cvs-commit] r1774 - trunk/Drivers/ccid/src

Ludovic Rousseau rousseau at costa.debian.org
Tue Nov 29 13:54:07 UTC 2005


Author: rousseau
Date: 2005-11-29 13:54:07 +0000 (Tue, 29 Nov 2005)
New Revision: 1774

Modified:
   trunk/Drivers/ccid/src/ifdhandler.c
Log:
Avoid a possible division by 0 if f or d parameter is null.
This could happen only with non-ISO cards with TA1=0x00 or other
undefined values


Modified: trunk/Drivers/ccid/src/ifdhandler.c
===================================================================
--- trunk/Drivers/ccid/src/ifdhandler.c	2005-11-29 13:43:40 UTC (rev 1773)
+++ trunk/Drivers/ccid/src/ifdhandler.c	2005-11-29 13:54:07 UTC (rev 1774)
@@ -466,6 +466,14 @@
 			ATR_GetParameter(&atr, ATR_PARAMETER_D, &d);
 			ATR_GetParameter(&atr, ATR_PARAMETER_F, &f);
 
+			/* may happen with non ISO cards */
+			if ((0 == f) || (0 == d))
+			{
+				/* values for TA1=11 */
+				f = 372;
+				d = 1;
+			}
+
 			/* Baudrate = f x D/F */
 			card_baudrate = (unsigned int) (1000 * ccid_desc->dwDefaultClock
 				* d / f);
@@ -1133,6 +1141,10 @@
 	ATR_GetParameter(atr, ATR_PARAMETER_D, &d);
 	ATR_GetParameter(atr, ATR_PARAMETER_F, &f);
 
+	/* may happen with non ISO cards */
+	if ((0 == f) || (0 == d))
+		return;
+
 	/* Baudrate = f x D/F */
 	card_baudrate = (unsigned int) (1000 * ccid_desc->dwDefaultClock * d / f);
 
@@ -1233,6 +1245,10 @@
 	/* clock_frequency is in kHz so the times are in milliseconds and not
 	 * in seconds */
 
+	/* may happen with non ISO cards */
+	if ((0 == f) || (0 == d) || (0 == clock_frequency))
+		return 60;	/* 60 seconds */
+
 	/* EGT */
 	/* see ch. 6.5.3 Extra Guard Time, page 12 of ISO 7816-3 */
 	EGT = 12 * f / d / clock_frequency + (f / d) * TC1 / clock_frequency;
@@ -1279,6 +1295,10 @@
 	/* clock_frequency is in kHz so the times are in milliseconds and not
 	 * in seconds */
 
+	/* may happen with non ISO cards */
+	if ((0 == f) || (0 == d) || (0 == clock_frequency))
+		return 60;	/* 60 seconds */
+
 	/* see ch. 6.5.2 Transmission factors F and D, page 12 of ISO 7816-3 */
 	etu = f / d / clock_frequency;
 




More information about the Pcsclite-cvs-commit mailing list