[Pcsclite-cvs-commit] r3267 - /trunk/PCSC/src/winscard_svc.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Mon Jan 5 13:58:15 UTC 2009


Author: rousseau
Date: Mon Jan  5 13:58:14 2009
New Revision: 3267

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3267
Log:
use offsetof(transmit_struct_extended, data) instead of sizeof(*treStr) since
from revision 2146 the data[] array has one element to be compilable by Sun
Studio 11

The side effect is that extended APDU were corrupted by 4 zero bytes between the two consecutive blocks


Modified:
    trunk/PCSC/src/winscard_svc.c

Modified: trunk/PCSC/src/winscard_svc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_svc.c?rev=3267&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_svc.c (original)
+++ trunk/PCSC/src/winscard_svc.c Mon Jan  5 13:58:14 2009
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <stdio.h>
 #include <string.h>
+#include <stddef.h>
 
 #include "pcscd.h"
 #include "winscard.h"
@@ -473,11 +474,11 @@
 			{
 				/* copy the first APDU part */
 				memcpy(pbSendBuffer, treStr->data,
-					PCSCLITE_MAX_MESSAGE_SIZE-sizeof(*treStr));
+					PCSCLITE_MAX_MESSAGE_SIZE-offsetof(transmit_struct_extended, data));
 
 				/* receive the second block */
 				rv = SHMMessageReceive(
-					pbSendBuffer+PCSCLITE_MAX_MESSAGE_SIZE-sizeof(*treStr),
+					pbSendBuffer+PCSCLITE_MAX_MESSAGE_SIZE-offsetof(transmit_struct_extended, data),
 					treStr->size - PCSCLITE_MAX_MESSAGE_SIZE,
 					psContext[dwContextIndex].dwClientID,
 					PCSCLITE_SERVER_ATTEMPTS);
@@ -504,12 +505,12 @@
 			treStr->pioRecvPciLength = ioRecvPci.cbPciLength;
 			treStr->pcbRecvLength = cbRecvLength;
 
-			treStr->size = sizeof(*treStr) + treStr->pcbRecvLength;
+			treStr->size = offsetof(transmit_struct_extended, data) + treStr->pcbRecvLength;
 			if (treStr->size > PCSCLITE_MAX_MESSAGE_SIZE)
 			{
 				/* two blocks */
 				memcpy(treStr->data, pbRecvBuffer, PCSCLITE_MAX_MESSAGE_SIZE
-					- sizeof(*treStr));
+					- offsetof(transmit_struct_extended, data));
 
 				rv = SHMMessageSend(msgStruct, sizeof(*msgStruct),
 					psContext[dwContextIndex].dwClientID,
@@ -518,7 +519,7 @@
 					Log1(PCSC_LOG_CRITICAL, "transmission failed");
 
 				rv = SHMMessageSend(pbRecvBuffer + PCSCLITE_MAX_MESSAGE_SIZE
-					- sizeof(*treStr),
+					- offsetof(transmit_struct_extended, data),
 					treStr->size - PCSCLITE_MAX_MESSAGE_SIZE,
 					psContext[dwContextIndex].dwClientID,
 					PCSCLITE_SERVER_ATTEMPTS);




More information about the Pcsclite-cvs-commit mailing list