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
This commit is contained in:
frankmorgner
2010-07-12 12:18:04 +00:00
parent 367afc4406
commit deaf8a8096
3 changed files with 27 additions and 21 deletions

View File

@@ -87,7 +87,7 @@ Index: ccid-1.3.11/src/commands.c
/***************************************************************************** /*****************************************************************************
@@ -691,7 +703,304 @@ @@ -691,7 +703,306 @@
return ret; return ret;
} /* SecurePINModify */ } /* SecurePINModify */
@@ -172,8 +172,8 @@ Index: ccid-1.3.11/src/commands.c
+ DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription);
+ parsed += lengthCertificateDescription; + parsed += lengthCertificateDescription;
+ +
+ if (parsed != input_length) { + if (parsed < input_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -191,7 +191,7 @@ Index: ccid-1.3.11/src/commands.c
+ DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + DEBUG_CRITICAL("Malformed Establish PACE Channel output data.");
+ return IFD_COMMUNICATION_ERROR; + 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]); + output[parsed+0], output[parsed+1]);
+ parsed += 2; + parsed += 2;
+ +
@@ -200,6 +200,7 @@ Index: ccid-1.3.11/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ lengthEF_CardAccess = w2i(output, parsed); + lengthEF_CardAccess = w2i(output, parsed);
+ memcpy(&output[parsed], &lengthEF_CardAccess, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+lengthEF_CardAccess > output_length) { + if (parsed+lengthEF_CardAccess > output_length) {
@@ -247,6 +248,7 @@ Index: ccid-1.3.11/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ length_IDicc = w2i(output, parsed); + length_IDicc = w2i(output, parsed);
+ memcpy(&output[parsed], &length_IDicc, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+length_IDicc > output_length) { + 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); + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc);
+ parsed += length_IDicc; + parsed += length_IDicc;
+ +
+ if (parsed != output_length) { + if (parsed < output_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -392,7 +394,7 @@ Index: ccid-1.3.11/src/commands.c
/***************************************************************************** /*****************************************************************************
* *
* Escape * Escape
@@ -2081,3 +2390,15 @@ @@ -2081,3 +2392,15 @@
buffer[3] = (value >> 24) & 0xFF; buffer[3] = (value >> 24) & 0xFF;
} /* i2dw */ } /* i2dw */

View File

@@ -87,7 +87,7 @@ Index: ccid-1.3.11/src/commands.c
/***************************************************************************** /*****************************************************************************
@@ -712,7 +724,304 @@ @@ -712,7 +724,306 @@
return ret; return ret;
} /* SecurePINModify */ } /* SecurePINModify */
@@ -172,8 +172,8 @@ Index: ccid-1.3.11/src/commands.c
+ DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription);
+ parsed += lengthCertificateDescription; + parsed += lengthCertificateDescription;
+ +
+ if (parsed != input_length) { + if (parsed < input_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -191,7 +191,7 @@ Index: ccid-1.3.11/src/commands.c
+ DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + DEBUG_CRITICAL("Malformed Establish PACE Channel output data.");
+ return IFD_COMMUNICATION_ERROR; + 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]); + output[parsed+0], output[parsed+1]);
+ parsed += 2; + parsed += 2;
+ +
@@ -200,6 +200,7 @@ Index: ccid-1.3.11/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ lengthEF_CardAccess = w2i(output, parsed); + lengthEF_CardAccess = w2i(output, parsed);
+ memcpy(&output[parsed], &lengthEF_CardAccess, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+lengthEF_CardAccess > output_length) { + if (parsed+lengthEF_CardAccess > output_length) {
@@ -247,6 +248,7 @@ Index: ccid-1.3.11/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ length_IDicc = w2i(output, parsed); + length_IDicc = w2i(output, parsed);
+ memcpy(&output[parsed], &length_IDicc, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+length_IDicc > output_length) { + 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); + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc);
+ parsed += length_IDicc; + parsed += length_IDicc;
+ +
+ if (parsed != output_length) { + if (parsed < output_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -392,7 +394,7 @@ Index: ccid-1.3.11/src/commands.c
/***************************************************************************** /*****************************************************************************
* *
* Escape * Escape
@@ -2113,3 +2422,15 @@ @@ -2113,3 +2424,15 @@
buffer[3] = (value >> 24) & 0xFF; buffer[3] = (value >> 24) & 0xFF;
} /* i2dw */ } /* i2dw */

View File

@@ -99,7 +99,7 @@ Index: Drivers/ccid/src/commands.c
/***************************************************************************** /*****************************************************************************
@@ -712,7 +724,304 @@ @@ -712,7 +724,306 @@
return ret; return ret;
} /* SecurePINModify */ } /* SecurePINModify */
@@ -184,8 +184,8 @@ Index: Drivers/ccid/src/commands.c
+ DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription); + DEBUG_INFO_XXD("Certificate description:\n", &input[parsed], lengthCertificateDescription);
+ parsed += lengthCertificateDescription; + parsed += lengthCertificateDescription;
+ +
+ if (parsed != input_length) { + if (parsed < input_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", input_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", input_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -203,7 +203,7 @@ Index: Drivers/ccid/src/commands.c
+ DEBUG_CRITICAL("Malformed Establish PACE Channel output data."); + DEBUG_CRITICAL("Malformed Establish PACE Channel output data.");
+ return IFD_COMMUNICATION_ERROR; + 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]); + output[parsed+0], output[parsed+1]);
+ parsed += 2; + parsed += 2;
+ +
@@ -212,6 +212,7 @@ Index: Drivers/ccid/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ lengthEF_CardAccess = w2i(output, parsed); + lengthEF_CardAccess = w2i(output, parsed);
+ memcpy(&output[parsed], &lengthEF_CardAccess, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+lengthEF_CardAccess > output_length) { + if (parsed+lengthEF_CardAccess > output_length) {
@@ -259,6 +260,7 @@ Index: Drivers/ccid/src/commands.c
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ length_IDicc = w2i(output, parsed); + length_IDicc = w2i(output, parsed);
+ memcpy(&output[parsed], &length_IDicc, 2);
+ parsed += 2; + parsed += 2;
+ +
+ if (parsed+length_IDicc > output_length) { + 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); + DEBUG_INFO_XXD("IDicc:\n", &output[parsed], length_IDicc);
+ parsed += length_IDicc; + parsed += length_IDicc;
+ +
+ if (parsed != output_length) { + if (parsed < output_length) {
+ DEBUG_CRITICAL2("Overrun by %d bytes", output_length - parsed); + DEBUG_CRITICAL2("Overrun by %u bytes", output_length - parsed);
+ return IFD_COMMUNICATION_ERROR; + return IFD_COMMUNICATION_ERROR;
+ } + }
+ +
@@ -404,7 +406,7 @@ Index: Drivers/ccid/src/commands.c
/***************************************************************************** /*****************************************************************************
* *
* Escape * Escape
@@ -2113,3 +2422,15 @@ @@ -2113,3 +2424,15 @@
buffer[3] = (value >> 24) & 0xFF; buffer[3] = (value >> 24) & 0xFF;
} /* i2dw */ } /* i2dw */