Juan Lang : crypt32: Simplify CRYPT_AsnDecodeIntInternal.
Alexandre Julliard
julliard at winehq.org
Mon Oct 19 09:56:06 CDT 2009
Module: wine
Branch: master
Commit: 4e300b6defe488feecb36a5cab223c6c78998c66
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4e300b6defe488feecb36a5cab223c6c78998c66
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Oct 15 15:12:40 2009 -0700
crypt32: Simplify CRYPT_AsnDecodeIntInternal.
---
dlls/crypt32/decode.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 9da367b..ede5af2 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -3915,38 +3915,40 @@ static BOOL CRYPT_AsnDecodeIntInternal(const BYTE *pbEncoded, DWORD cbEncoded,
DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded)
{
BOOL ret;
- BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)];
- CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf;
- DWORD size = sizeof(buf);
+ DWORD dataLen;
- blob->pbData = buf + sizeof(CRYPT_INTEGER_BLOB);
- ret = CRYPT_AsnDecodeIntegerInternal(pbEncoded, cbEncoded, 0, buf,
- &size, pcbDecoded);
- if (ret)
+ if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
{
- if (!pvStructInfo)
+ BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
+
+ if (pcbDecoded)
+ *pcbDecoded = 1 + lenBytes + dataLen;
+ if (dataLen > sizeof(int))
+ {
+ SetLastError(CRYPT_E_ASN1_LARGE);
+ ret = FALSE;
+ }
+ else if (!pvStructInfo)
*pcbStructInfo = sizeof(int);
else if ((ret = CRYPT_DecodeCheckSpace(pcbStructInfo, sizeof(int))))
{
int val, i;
- if (blob->pbData[blob->cbData - 1] & 0x80)
+ if (dataLen && pbEncoded[1 + lenBytes] & 0x80)
{
/* initialize to a negative value to sign-extend */
val = -1;
}
else
val = 0;
- for (i = 0; i < blob->cbData; i++)
+ for (i = 0; i < dataLen; i++)
{
val <<= 8;
- val |= blob->pbData[blob->cbData - i - 1];
+ val |= pbEncoded[1 + lenBytes + i];
}
memcpy(pvStructInfo, &val, sizeof(int));
}
}
- else if (GetLastError() == ERROR_MORE_DATA)
- SetLastError(CRYPT_E_ASN1_LARGE);
return ret;
}
More information about the wine-cvs
mailing list