Module: wine Branch: master Commit: be91ad360437363bf91aae977a95d8244df8dee9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=be91ad360437363bf91aae977a...
Author: Juan Lang juan.lang@gmail.com Date: Mon Sep 17 17:21:43 2007 -0700
crypt32: Simplify DecodePathLenConstraint.
---
dlls/crypt32/decode.c | 54 ++++++++++++++++++++---------------------------- 1 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index 9fba88c..7b231ea 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -2602,43 +2602,35 @@ static BOOL CRYPT_AsnDecodePathLenConstraint(const BYTE *pbEncoded, DWORD *pcbDecoded) { BOOL ret = TRUE; + DWORD bytesNeeded = sizeof(struct PATH_LEN_CONSTRAINT), size;
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, pvStructInfo, *pcbStructInfo, pcbDecoded);
- if (cbEncoded) + if (!pvStructInfo) { - if (pbEncoded[0] == ASN_INTEGER) - { - DWORD bytesNeeded = sizeof(struct PATH_LEN_CONSTRAINT); - - if (!pvStructInfo) - *pcbStructInfo = bytesNeeded; - else if (*pcbStructInfo < bytesNeeded) - { - SetLastError(ERROR_MORE_DATA); - *pcbStructInfo = bytesNeeded; - ret = FALSE; - } - else - { - struct PATH_LEN_CONSTRAINT *constraint = - (struct PATH_LEN_CONSTRAINT *)pvStructInfo; - DWORD size = sizeof(constraint->dwPathLenConstraint); + ret = CRYPT_AsnDecodeIntInternal(pbEncoded, cbEncoded, dwFlags, NULL, + &size, pcbDecoded); + *pcbStructInfo = bytesNeeded; + } + else if (*pcbStructInfo < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + *pcbStructInfo = bytesNeeded; + ret = FALSE; + } + else + { + struct PATH_LEN_CONSTRAINT *constraint = + (struct PATH_LEN_CONSTRAINT *)pvStructInfo;
- ret = CRYPT_AsnDecodeIntInternal(pbEncoded, cbEncoded, dwFlags, - &constraint->dwPathLenConstraint, &size, pcbDecoded); - if (ret) - constraint->fPathLenConstraint = TRUE; - TRACE("got an int, dwPathLenConstraint is %d\n", - constraint->dwPathLenConstraint); - } - } - else - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - ret = FALSE; - } + size = sizeof(constraint->dwPathLenConstraint); + ret = CRYPT_AsnDecodeIntInternal(pbEncoded, cbEncoded, dwFlags, + &constraint->dwPathLenConstraint, &size, pcbDecoded); + if (ret) + constraint->fPathLenConstraint = TRUE; + TRACE("got an int, dwPathLenConstraint is %d\n", + constraint->dwPathLenConstraint); } TRACE("returning %d (%08x)\n", ret, GetLastError()); return ret;