Changeset 21354 for trunk/src/crypt32/decode.c
- Timestamp:
- Feb 21, 2010, 5:32:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/crypt32/decode.c
r21311 r21354 38 38 #include <stdio.h> 39 39 #include <stdlib.h> 40 #include <string.h> 41 #include <ctype.h> 40 42 41 43 #define NONAMELESSUNION … … 46 48 #include "winnls.h" 47 49 #include "snmp.h" 48 #include "wine /debug.h"49 #include "wine /exception.h"50 #include "wine\debug.h" 51 #include "wine\exception.h" 50 52 #include "crypt32_private.h" 51 53 … … 224 226 *(BYTE **)pvStructInfo = pDecodePara->pfnAlloc(bytesNeeded); 225 227 else 226 *(BYTE **)pvStructInfo = LocalAlloc(0, bytesNeeded);228 *(BYTE **)pvStructInfo = (BYTE*)LocalAlloc(0, bytesNeeded); 227 229 if (!*(BYTE **)pvStructInfo) 228 230 ret = FALSE; … … 246 248 pDecodePara->pfnFree(pv); 247 249 else 248 LocalFree( pv);250 LocalFree((HANDLE)pv); 249 251 } 250 252 … … 329 331 330 332 if ((ret = CRYPT_GetLengthIndefinite(ptr, 331 cbEncoded - (ptr - pbEncoded), &itemLen)) )333 cbEncoded - (ptr - pbEncoded), &itemLen)) != FALSE) 332 334 { 333 335 BYTE itemLenBytes = GET_LEN_BYTES(ptr[1]); … … 484 486 DWORD dataLen; 485 487 486 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) )488 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) != FALSE) 487 489 { 488 490 DWORD lenBytes = GET_LEN_BYTES(pbEncoded[1]), cbDecoded; … … 547 549 *pcbStructInfo = bytesNeeded; 548 550 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, 549 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) )551 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 550 552 { 551 553 BYTE *nextData; … … 623 625 DWORD dataLen; 624 626 625 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) )627 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) != FALSE) 626 628 { 627 629 DWORD bytesNeeded, cItems = 0, decoded; … … 664 666 */ 665 667 if ((ret = CRYPT_GetLengthIndefinite(ptr, 666 cbEncoded - (ptr - pbEncoded), &itemDataLen)) )668 cbEncoded - (ptr - pbEncoded), &itemDataLen)) != FALSE) 667 669 { 668 670 if (itemDataLen == CMSG_INDEFINITE_LENGTH) … … 712 714 *pcbStructInfo = bytesNeeded; 713 715 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, 714 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) )716 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 715 717 { 716 718 DWORD i; … … 778 780 DWORD dataLen; 779 781 780 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )782 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 781 783 { 782 784 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 790 792 if (!pvStructInfo) 791 793 *pcbStructInfo = bytesNeeded; 792 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, bytesNeeded)) )794 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, bytesNeeded)) != FALSE) 793 795 { 794 796 CRYPT_DER_BLOB *blob; … … 902 904 DWORD dataLen; 903 905 904 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )906 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 905 907 { 906 908 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 939 941 DWORD dataLen; 940 942 941 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )943 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 942 944 { 943 945 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 1046 1048 signedCert->ToBeSigned.cbData, dwFlags, pDecodePara, 1047 1049 pvStructInfo, pcbStructInfo); 1048 LocalFree( signedCert);1050 LocalFree((HANDLE)signedCert); 1049 1051 } 1050 1052 } … … 1186 1188 signedCrl->ToBeSigned.cbData, dwFlags, pDecodePara, 1187 1189 pvStructInfo, pcbStructInfo); 1188 LocalFree( signedCrl);1190 LocalFree((HANDLE)signedCrl); 1189 1191 } 1190 1192 } … … 1217 1219 pvStructInfo, *pcbStructInfo); 1218 1220 1219 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )1221 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 1220 1222 { 1221 1223 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 1434 1436 CERT_NAME_VALUE *value = (CERT_NAME_VALUE *)pvStructInfo; 1435 1437 1436 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )1438 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 1437 1439 { 1438 1440 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 1621 1623 CERT_NAME_VALUE *value = (CERT_NAME_VALUE *)pvStructInfo; 1622 1624 1623 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )1625 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 1624 1626 { 1625 1627 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 1952 1954 done = TRUE; 1953 1955 else if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, 1954 &dataLen)) )1956 &dataLen)) != FALSE) 1955 1957 { 1956 1958 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 2004 2006 pvStructInfo, *pcbStructInfo); 2005 2007 2006 if ((ret = CRYPT_FindEncodedLen(pbEncoded, cbEncoded, &encodedLen)) )2008 if ((ret = CRYPT_FindEncodedLen(pbEncoded, cbEncoded, &encodedLen)) != FALSE) 2007 2009 { 2008 2010 if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) … … 2229 2231 else if ((ret = CRYPT_AsnDecodeSMIMECapabilitiesInternal(pbEncoded, 2230 2232 cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, 2231 NULL)) )2233 NULL)) != FALSE) 2232 2234 { 2233 2235 if (!pvStructInfo) 2234 2236 *pcbStructInfo = bytesNeeded; 2235 2237 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 2236 pvStructInfo, pcbStructInfo, bytesNeeded)) )2238 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 2237 2239 { 2238 2240 PCRYPT_SMIME_CAPABILITIES capabilities; … … 2267 2269 LPSTR *pStr = pvStructInfo; 2268 2270 2269 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )2271 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 2270 2272 { 2271 2273 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 2400 2402 DWORD dataLen; 2401 2403 2402 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )2404 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 2403 2405 { 2404 2406 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 2569 2571 *pcbStructInfo = bytesNeeded; 2570 2572 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 2571 pvStructInfo, pcbStructInfo, bytesNeeded)) )2573 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 2572 2574 { 2573 2575 PCERT_POLICY_QUALIFIER_USER_NOTICE notice; … … 2640 2642 *pcbStructInfo = bytesNeeded; 2641 2643 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 2642 pvStructInfo, pcbStructInfo, bytesNeeded)) )2644 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 2643 2645 { 2644 2646 PCRYPT_ATTRIBUTE attr; … … 2699 2701 else if ((ret = CRYPT_AsnDecodePKCSAttributesInternal(pbEncoded, 2700 2702 cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, 2701 NULL)) )2703 NULL)) != FALSE) 2702 2704 { 2703 2705 if (!pvStructInfo) 2704 2706 *pcbStructInfo = bytesNeeded; 2705 2707 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 2706 pvStructInfo, pcbStructInfo, bytesNeeded)) )2708 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 2707 2709 { 2708 2710 PCRYPT_ATTRIBUTES attrs; … … 2790 2792 2791 2793 if ((ret = CRYPT_AsnDecodePubKeyInfoInternal(pbEncoded, cbEncoded, 2792 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) )2794 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) != FALSE) 2793 2795 { 2794 2796 if (!pvStructInfo) 2795 2797 *pcbStructInfo = bytesNeeded; 2796 2798 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 2797 pvStructInfo, pcbStructInfo, bytesNeeded)) )2799 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 2798 2800 { 2799 2801 PCERT_PUBLIC_KEY_INFO info; … … 2883 2885 return FALSE; 2884 2886 } 2885 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )2887 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 2886 2888 { 2887 2889 switch (pbEncoded[0] & ASN_TYPE_MASK) … … 3168 3170 * Check the outer length is valid: 3169 3171 */ 3170 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) )3172 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)) != FALSE) 3171 3173 { 3172 3174 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 3178 3180 cbEncoded -= 2; /* space for 0 TLV */ 3179 3181 /* Check the inner length is valid: */ 3180 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &innerLen)) )3182 if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &innerLen)) != FALSE) 3181 3183 { 3182 3184 DWORD decodedLen; … … 3314 3316 3315 3317 if ((ret = CRYPT_AsnDecodeAltNameInternal(pbEncoded, cbEncoded, 3316 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) )3318 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) != FALSE) 3317 3319 { 3318 3320 if (!pvStructInfo) 3319 3321 *pcbStructInfo = bytesNeeded; 3320 3322 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 3321 pvStructInfo, pcbStructInfo, bytesNeeded)) )3323 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 3322 3324 { 3323 3325 CERT_ALT_NAME_INFO *name; … … 3607 3609 } 3608 3610 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 3609 pvStructInfo, pcbStructInfo, bytesNeeded)) )3611 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 3610 3612 { 3611 3613 BLOBHEADER *hdr; … … 3628 3630 decodedKey->modulus.cbData); 3629 3631 } 3630 LocalFree( decodedKey);3632 LocalFree((HANDLE)decodedKey); 3631 3633 } 3632 3634 } … … 3650 3652 pvStructInfo, *pcbStructInfo, pcbDecoded); 3651 3653 3652 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )3654 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 3653 3655 { 3654 3656 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 3713 3715 } 3714 3716 else if ((ret = CRYPT_AsnDecodeOctetsInternal(pbEncoded, cbEncoded, 3715 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) )3717 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) != FALSE) 3716 3718 { 3717 3719 if (!pvStructInfo) 3718 3720 *pcbStructInfo = bytesNeeded; 3719 3721 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 3720 pvStructInfo, pcbStructInfo, bytesNeeded)) )3722 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 3721 3723 { 3722 3724 CRYPT_DATA_BLOB *blob; … … 3751 3753 pvStructInfo, *pcbStructInfo, pcbDecoded); 3752 3754 3753 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )3755 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 3754 3756 { 3755 3757 if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) … … 3820 3822 } 3821 3823 else if ((ret = CRYPT_AsnDecodeBitsInternal(pbEncoded, cbEncoded, 3822 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) )3824 dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) != FALSE) 3823 3825 { 3824 3826 if (!pvStructInfo) 3825 3827 *pcbStructInfo = bytesNeeded; 3826 3828 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 3827 pvStructInfo, pcbStructInfo, bytesNeeded)) )3829 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 3828 3830 { 3829 3831 CRYPT_BIT_BLOB *blob; … … 3865 3867 if (!pvStructInfo) 3866 3868 *pcbStructInfo = sizeof(int); 3867 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, sizeof(int))) )3869 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, sizeof(int))) != FALSE) 3868 3870 { 3869 3871 int val, i; … … 3917 3919 *pcbStructInfo = bytesNeeded; 3918 3920 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 3919 pvStructInfo, pcbStructInfo, bytesNeeded)) )3921 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 3920 3922 { 3921 3923 if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) … … 3943 3945 DWORD bytesNeeded, dataLen; 3944 3946 3945 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )3947 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 3946 3948 { 3947 3949 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 4003 4005 *pcbStructInfo = bytesNeeded; 4004 4006 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 4005 pvStructInfo, pcbStructInfo, bytesNeeded)) )4007 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 4006 4008 { 4007 4009 CRYPT_INTEGER_BLOB *blob; … … 4037 4039 DWORD bytesNeeded, dataLen; 4038 4040 4039 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )4041 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 4040 4042 { 4041 4043 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); … … 4097 4099 4098 4100 if ((ret = CRYPT_AsnDecodeUnsignedIntegerInternal(pbEncoded, cbEncoded, 4099 dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) )4101 dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL)) != FALSE) 4100 4102 { 4101 4103 if (!pvStructInfo) 4102 4104 *pcbStructInfo = bytesNeeded; 4103 4105 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 4104 pvStructInfo, pcbStructInfo, bytesNeeded)) )4106 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 4105 4107 { 4106 4108 CRYPT_INTEGER_BLOB *blob; … … 4171 4173 } 4172 4174 if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 4173 pvStructInfo, pcbStructInfo, sizeof(unsigned int))) )4175 pvStructInfo, pcbStructInfo, sizeof(unsigned int))) != FALSE) 4174 4176 { 4175 4177 if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) … … 4329 4331 *pcbStructInfo = sizeof(FILETIME); 4330 4332 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, 4331 sizeof(FILETIME))) )4333 sizeof(FILETIME))) != FALSE) 4332 4334 ret = SystemTimeToFileTime(&sysTime, 4333 4335 (FILETIME *)pvStructInfo); … … 4358 4360 *pcbStructInfo = bytesNeeded; 4359 4361 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, 4360 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) )4362 pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 4361 4363 { 4362 4364 if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) … … 4437 4439 *pcbStructInfo = sizeof(FILETIME); 4438 4440 else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, 4439 sizeof(FILETIME))) )4441 sizeof(FILETIME))) != FALSE) 4440 4442 ret = SystemTimeToFileTime(&sysTime, 4441 4443 (FILETIME *)pvStructInfo); … … 4488 4490 *pcbStructInfo = bytesNeeded; 4489 4491 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 4490 pvStructInfo, pcbStructInfo, bytesNeeded)) )4492 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 4491 4493 { 4492 4494 if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) … … 4519 4521 DWORD bytesNeeded, dataLen, remainingLen, cValue; 4520 4522 4521 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )4523 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 4522 4524 { 4523 4525 BYTE lenBytes; … … 4555 4557 *pcbStructInfo = bytesNeeded; 4556 4558 else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, 4557 pvStructInfo, pcbStructInfo, bytesNeeded)) )4559 pvStructInfo, pcbStructInfo, bytesNeeded)) != FALSE) 4558 4560 { 4559 4561 if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) … … 4622 4624 DWORD bytesNeeded, dataLen; 4623 4625 4624 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) )4626 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) != FALSE) 4625 4627 { 4626 4628 struct AsnArrayDescriptor arrayDesc = {
Note:
See TracChangeset
for help on using the changeset viewer.