libwinpr-winscard: add WINPR_WINSCARD_LOCK_TRANSACTIONS environment variable, fix...
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 20 Jan 2015 20:29:05 +0000 (15:29 -0500)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 20 Jan 2015 20:29:05 +0000 (15:29 -0500)
channels/smartcard/client/smartcard_pack.c
winpr/libwinpr/smartcard/smartcard_pcsc.c
winpr/libwinpr/utils/print.c

index dd00a1f..3ae3438 100644 (file)
@@ -2091,6 +2091,13 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
        Stream_Read_UINT32(s, call->fpbRecvBufferIsNULL); /* fpbRecvBufferIsNULL (4 bytes) */
        Stream_Read_UINT32(s, call->cbRecvLength); /* cbRecvLength (4 bytes) */
 
+       if (pioRecvPciNdrPtr)
+       {
+               WLog_WARN(TAG, "Transmit_Call with pioRecvPci:");
+               winpr_HexDump(TAG, WLOG_WARN, Stream_Pointer(s) - 32,
+                               Stream_GetRemainingLength(s) + 32);
+       }
+
        if (ioSendPci.cbExtraBytes > 1024)
        {
                WLog_WARN(TAG, "Transmit_Call ioSendPci.cbExtraBytes is out of bounds: %d (max: %d)",
index 5bad1b4..9d50ac0 100644 (file)
@@ -2811,8 +2811,27 @@ extern int PCSC_InitializeSCardApi_Link(void);
 
 int PCSC_InitializeSCardApi(void)
 {
+       DWORD nSize;
+       char* env = NULL;
+
+       nSize = GetEnvironmentVariableA("WINPR_WINSCARD_LOCK_TRANSACTIONS", NULL, 0);
+
+       if (nSize)
+       {
+               env = (LPSTR) malloc(nSize);
+               nSize = GetEnvironmentVariableA("WINPR_WINSCARD_LOCK_TRANSACTIONS", env, nSize);
+
+               if (strcmp(env, "1") == 0)
+                       g_LockTransactions = TRUE;
+               else if (strcmp(env, "0") == 0)
+                       g_LockTransactions = FALSE;
+
+               free(env);
+       }
+
        /* Disable pcsc-lite's (poor) blocking so we can handle it ourselves */
        SetEnvironmentVariableA("PCSCLITE_NO_BLOCKING", "1");
+
 #ifndef DISABLE_PCSC_LINK
 
        if (PCSC_InitializeSCardApi_Link() >= 0)
index 20bdae4..4fa7e61 100644 (file)
@@ -65,7 +65,6 @@ void winpr_HexDump(const char* tag, int level, const BYTE* data, int length)
                        pos += trio_snprintf(&buffer[pos], blen - pos, "%c",
                                                        (p[i] >= 0x20 && p[i] < 0x7F) ? p[i] : '.');
 
-               pos += trio_snprintf(&buffer[pos], blen - pos, "\n");
                WLog_LVL(tag, level, "%s", buffer);
                offset += line;
                p += line;