fixed problems parsing pin modification data structure

git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@520 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2011-09-02 19:29:10 +00:00
parent e1e359b440
commit 0f979c9563
3 changed files with 27 additions and 6 deletions

View File

@@ -1197,7 +1197,8 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
modify = (abPINDataStucture_Modification_t *)
(abData + sizeof(__u8));
if (abDatalen < sizeof *modify) {
/* bTeoPrologue adds another 3 bytes */
if (abDatalen < sizeof *modify + 3*(sizeof(__u8))) {
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "Not enough data for abPINDataStucture_Modification_t");
sc_result = SC_ERROR_INVALID_DATA;
goto err;
@@ -1208,7 +1209,27 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
bmPINBlockString = modify->bmPINBlockString;
bmFormatString = modify->bmFormatString;
bNumberMessage = modify->bNumberMessage;
abPINApdu = (__u8*) modify + sizeof *modify;
/* bTeoPrologue adds another 3 bytes */
abPINApdu = (__u8*) modify + sizeof *modify + 3*(sizeof(__u8));
if (bNumberMessage != 0x00) {
/* bMsgIndex2 is present */
abPINApdu++;
if (abDatalen < sizeof *modify + 4*(sizeof(__u8))) {
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "Not enough data for abPINDataStucture_Modification_t");
sc_result = SC_ERROR_INVALID_DATA;
goto err;
}
if (bNumberMessage == 0x03) {
/* bMsgIndex3 is present */
abPINApdu++;
if (abDatalen < sizeof *modify + 5*(sizeof(__u8))) {
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "Not enough data for abPINDataStucture_Modification_t");
sc_result = SC_ERROR_INVALID_DATA;
goto err;
}
}
}
apdulen = __le32_to_cpu(request->dwLength) - sizeof *modify - sizeof(__u8);
break;
case 0x10:

View File

@@ -160,10 +160,6 @@ typedef struct {
__u8 bNumberMessage;
__le16 wLangId;
__u8 bMsgIndex1;
__u8 bMsgIndex2;
__u8 bMsgIndex3;
__u8 bTeoPrologue1;
__le16 bTeoPrologue2;
} __attribute__ ((packed)) abPINDataStucture_Modification_t;
typedef struct {