From deaf8a809654ff97743cd8f77f9f4d68423d3849 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Mon, 12 Jul 2010 12:18:04 +0000 Subject: [PATCH] bugfix: transform pace output buffer on usb from little endian to host byte order git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@211 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/patches/ccid-1.3.11.patch | 16 +++++++++------- ccid/patches/ccid-1.3.13.patch | 16 +++++++++------- ccid/patches/pcsclite_trunk_r5067.patch | 16 +++++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ccid/patches/ccid-1.3.11.patch b/ccid/patches/ccid-1.3.11.patch index 803906d..d17df62 100644 --- a/ccid/patches/ccid-1.3.11.patch +++ b/ccid/patches/ccid-1.3.11.patch @@ -87,7 +87,7 @@ Index: ccid-1.3.11/src/commands.c /***************************************************************************** -@@ -691,7 +703,304 @@ +@@ -691,7 +703,306 @@ return ret; } /* SecurePINModify */ @@ -172,8 +172,8 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + parsed += lengthCertificateDescription; + -+ if (parsed != input_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); ++ if (parsed < input_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -191,7 +191,7 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + return IFD_COMMUNICATION_ERROR; + } -+ DEBUG_COMM3("MSE:Set AT Statusbytes: %02X %02X", ++ DEBUG_INFO3("MSE:Set AT Statusbytes: %02X %02X", + output[parsed+0], output[parsed+1]); + parsed += 2; + @@ -200,6 +200,7 @@ Index: ccid-1.3.11/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + lengthEF_CardAccess = w2i(output, parsed); ++ memcpy(&output[parsed], &lengthEF_CardAccess, 2); + parsed += 2; + + if (parsed+lengthEF_CardAccess > output_length) { @@ -247,6 +248,7 @@ Index: ccid-1.3.11/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + length_IDicc = w2i(output, parsed); ++ memcpy(&output[parsed], &length_IDicc, 2); + parsed += 2; + + if (parsed+length_IDicc > output_length) { @@ -257,8 +259,8 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc); + parsed += length_IDicc; + -+ if (parsed != output_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); ++ if (parsed < output_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -392,7 +394,7 @@ Index: ccid-1.3.11/src/commands.c /***************************************************************************** * * Escape -@@ -2081,3 +2390,15 @@ +@@ -2081,3 +2392,15 @@ buffer[3] = (value >> 24) & 0xFF; } /* i2dw */ diff --git a/ccid/patches/ccid-1.3.13.patch b/ccid/patches/ccid-1.3.13.patch index 0df5a3d..68a4e2b 100644 --- a/ccid/patches/ccid-1.3.13.patch +++ b/ccid/patches/ccid-1.3.13.patch @@ -87,7 +87,7 @@ Index: ccid-1.3.11/src/commands.c /***************************************************************************** -@@ -712,7 +724,304 @@ +@@ -712,7 +724,306 @@ return ret; } /* SecurePINModify */ @@ -172,8 +172,8 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + parsed += lengthCertificateDescription; + -+ if (parsed != input_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); ++ if (parsed < input_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -191,7 +191,7 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + return IFD_COMMUNICATION_ERROR; + } -+ DEBUG_COMM3("MSE:Set AT Statusbytes: %02X %02X", ++ DEBUG_INFO3("MSE:Set AT Statusbytes: %02X %02X", + output[parsed+0], output[parsed+1]); + parsed += 2; + @@ -200,6 +200,7 @@ Index: ccid-1.3.11/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + lengthEF_CardAccess = w2i(output, parsed); ++ memcpy(&output[parsed], &lengthEF_CardAccess, 2); + parsed += 2; + + if (parsed+lengthEF_CardAccess > output_length) { @@ -247,6 +248,7 @@ Index: ccid-1.3.11/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + length_IDicc = w2i(output, parsed); ++ memcpy(&output[parsed], &length_IDicc, 2); + parsed += 2; + + if (parsed+length_IDicc > output_length) { @@ -257,8 +259,8 @@ Index: ccid-1.3.11/src/commands.c + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc); + parsed += length_IDicc; + -+ if (parsed != output_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); ++ if (parsed < output_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -392,7 +394,7 @@ Index: ccid-1.3.11/src/commands.c /***************************************************************************** * * Escape -@@ -2113,3 +2422,15 @@ +@@ -2113,3 +2424,15 @@ buffer[3] = (value >> 24) & 0xFF; } /* i2dw */ diff --git a/ccid/patches/pcsclite_trunk_r5067.patch b/ccid/patches/pcsclite_trunk_r5067.patch index c969f7c..c04735c 100644 --- a/ccid/patches/pcsclite_trunk_r5067.patch +++ b/ccid/patches/pcsclite_trunk_r5067.patch @@ -99,7 +99,7 @@ Index: Drivers/ccid/src/commands.c /***************************************************************************** -@@ -712,7 +724,304 @@ +@@ -712,7 +724,306 @@ return ret; } /* SecurePINModify */ @@ -184,8 +184,8 @@ Index: Drivers/ccid/src/commands.c + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + parsed += lengthCertificateDescription; + -+ if (parsed != input_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); ++ if (parsed < input_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -203,7 +203,7 @@ Index: Drivers/ccid/src/commands.c + DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + return IFD_COMMUNICATION_ERROR; + } -+ DEBUG_COMM3("MSE:Set AT Statusbytes: %02X %02X", ++ DEBUG_INFO3("MSE:Set AT Statusbytes: %02X %02X", + output[parsed+0], output[parsed+1]); + parsed += 2; + @@ -212,6 +212,7 @@ Index: Drivers/ccid/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + lengthEF_CardAccess = w2i(output, parsed); ++ memcpy(&output[parsed], &lengthEF_CardAccess, 2); + parsed += 2; + + if (parsed+lengthEF_CardAccess > output_length) { @@ -259,6 +260,7 @@ Index: Drivers/ccid/src/commands.c + return IFD_COMMUNICATION_ERROR; + } + length_IDicc = w2i(output, parsed); ++ memcpy(&output[parsed], &length_IDicc, 2); + parsed += 2; + + if (parsed+length_IDicc > output_length) { @@ -269,8 +271,8 @@ Index: Drivers/ccid/src/commands.c + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc); + parsed += length_IDicc; + -+ if (parsed != output_length) { -+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); ++ if (parsed < output_length) { ++ DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed); + return IFD_COMMUNICATION_ERROR; + } + @@ -404,7 +406,7 @@ Index: Drivers/ccid/src/commands.c /***************************************************************************** * * Escape -@@ -2113,3 +2422,15 @@ +@@ -2113,3 +2424,15 @@ buffer[3] = (value >> 24) & 0xFF; } /* i2dw */