Juan Lang : crypt32: Don't check tag in AsnDecodeIntInternal, caller already checks it.

Alexandre Julliard julliard at winehq.org
Fri Oct 12 05:22:58 CDT 2007


Module: wine
Branch: master
Commit: 30355fa674312de2780989d82fdd2e151741d37a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=30355fa674312de2780989d82fdd2e151741d37a

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Oct 10 17:49:33 2007 -0700

crypt32: Don't check tag in AsnDecodeIntInternal, caller already checks it.

---

 dlls/crypt32/decode.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 7bba04b..d0cf6cc 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -3118,6 +3118,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBits(DWORD dwCertEncodingType,
     return ret;
 }
 
+/* Ignores tag.  Only allows integers 4 bytes or smaller in size. */
 static BOOL CRYPT_AsnDecodeIntInternal(const BYTE *pbEncoded, DWORD cbEncoded,
  DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded)
 {
@@ -3127,14 +3128,8 @@ static BOOL CRYPT_AsnDecodeIntInternal(const BYTE *pbEncoded, DWORD cbEncoded,
     DWORD size = sizeof(buf);
 
     blob->pbData = buf + sizeof(CRYPT_INTEGER_BLOB);
-    if (pbEncoded[0] != ASN_INTEGER)
-    {
-        SetLastError(CRYPT_E_ASN1_BADTAG);
-        ret = FALSE;
-    }
-    else
-        ret = CRYPT_AsnDecodeIntegerInternal(pbEncoded, cbEncoded, 0, &buf,
-         &size, pcbDecoded);
+    ret = CRYPT_AsnDecodeIntegerInternal(pbEncoded, cbEncoded, 0, &buf,
+     &size, pcbDecoded);
     if (ret)
     {
         if (!pvStructInfo)
@@ -3173,8 +3168,19 @@ static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType,
     {
         DWORD bytesNeeded;
 
-        ret = CRYPT_AsnDecodeIntInternal(pbEncoded, cbEncoded,
-         dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL);
+        if (!cbEncoded)
+        {
+            SetLastError(CRYPT_E_ASN1_CORRUPT);
+            ret = FALSE;
+        }
+        else if (pbEncoded[0] != ASN_INTEGER)
+        {
+            SetLastError(CRYPT_E_ASN1_BADTAG);
+            ret = FALSE;
+        }
+        else
+            ret = CRYPT_AsnDecodeIntInternal(pbEncoded, cbEncoded,
+             dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL);
         if (ret)
         {
             if (!pvStructInfo)




More information about the wine-cvs mailing list