crypt32(15/25): Copy data in hash message update

Juan Lang juan.lang at gmail.com
Thu Jul 12 17:21:38 CDT 2007


--Juan
-------------- next part --------------
From 500e98b0786dddf25636dd6d82c1fdce076a4a2f Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 12 Jul 2007 14:52:41 -0700
Subject: [PATCH] Copy data in hash message update
---
 dlls/crypt32/msg.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 4668d2f..f247b23 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -315,15 +315,17 @@ static HCRYPTMSG CDataEncodeMsg_Open(DWO
 
 typedef struct _CHashEncodeMsg
 {
-    CryptMsgBase base;
-    HCRYPTPROV   prov;
-    HCRYPTHASH   hash;
+    CryptMsgBase    base;
+    HCRYPTPROV      prov;
+    HCRYPTHASH      hash;
+    CRYPT_DATA_BLOB data;
 } CHashEncodeMsg;
 
 static void CHashEncodeMsg_Close(HCRYPTMSG hCryptMsg)
 {
     CHashEncodeMsg *msg = (CHashEncodeMsg *)hCryptMsg;
 
+    CryptMemFree(msg->data.pbData);
     CryptDestroyHash(msg->hash);
     if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
         CryptReleaseContext(msg->prov, 0);
@@ -400,9 +402,22 @@ static BOOL CHashEncodeMsg_Update(HCRYPT
             else
             {
                 ret = CryptHashData(msg->hash, pbData, cbData, 0);
-                /* Still a stub, as content isn't modified */
-                FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData,
-                 fFinal);
+                if (ret)
+                {
+                    if (msg->data.pbData)
+                        msg->data.pbData = CryptMemRealloc(msg->data.pbData,
+                         msg->data.cbData + cbData);
+                    else
+                        msg->data.pbData = CryptMemAlloc(cbData);
+                    if (msg->data.pbData)
+                    {
+                        memcpy(msg->data.pbData + msg->data.cbData, pbData,
+                         cbData);
+                        msg->data.cbData += cbData;
+                    }
+                    else
+                        ret = FALSE;
+                }
             }
         }
     }
@@ -441,6 +456,8 @@ static HCRYPTMSG CHashEncodeMsg_Open(DWO
         CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
          CHashEncodeMsg_Close, CHashEncodeMsg_GetParam, CHashEncodeMsg_Update);
         msg->prov = prov;
+        msg->data.cbData = 0;
+        msg->data.pbData = NULL;
         if (!CryptCreateHash(prov, algID, 0, 0, &msg->hash))
         {
             CryptMsgClose(msg);
-- 
1.4.1


More information about the wine-patches mailing list