crypt32(18/25): Detached hash messages don't contain the content, so don't make a copy of it

Juan Lang juan.lang at gmail.com
Thu Jul 12 17:23:00 CDT 2007


--Juan
-------------- next part --------------
From 4fb06888e44429f22a44c95c71c4e212972eaa14 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 12 Jul 2007 14:56:30 -0700
Subject: [PATCH] Detached hash messages don't contain the content, so don't make a copy of it
---
 dlls/crypt32/msg.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 0bc3d0b..36194a3 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -387,27 +387,23 @@ static BOOL CHashEncodeMsg_Update(HCRYPT
     {
         if (fFinal)
             msg->base.finalized = TRUE;
-        if (msg->base.streamed)
+        if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG))
         {
-            /* Doesn't do anything, as stream output is never called, and you
+            /* Doesn't do much, as stream output is never called, and you
              * can't get the content.
              */
             ret = CryptHashData(msg->hash, pbData, cbData, 0);
         }
         else
         {
-            if (!(msg->base.open_flags & CMSG_DETACHED_FLAG) && !fFinal)
+            if (!fFinal)
                 SetLastError(CRYPT_E_MSG_ERROR);
             else
             {
                 ret = CryptHashData(msg->hash, pbData, cbData, 0);
                 if (ret)
                 {
-                    if (msg->data.pbData)
-                        msg->data.pbData = CryptMemRealloc(msg->data.pbData,
-                         msg->data.cbData + cbData);
-                    else
-                        msg->data.pbData = CryptMemAlloc(cbData);
+                    msg->data.pbData = CryptMemAlloc(cbData);
                     if (msg->data.pbData)
                     {
                         memcpy(msg->data.pbData + msg->data.cbData, pbData,
-- 
1.4.1


More information about the wine-patches mailing list