Juan Lang : rsaenh: Add error messages for failed private key imports.

Alexandre Julliard julliard at winehq.org
Tue Nov 1 13:23:19 CDT 2011


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

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Oct 26 16:02:03 2011 -0700

rsaenh: Add error messages for failed private key imports.

---

 dlls/rsaenh/rsaenh.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c
index db58e44..f332cfb 100644
--- a/dlls/rsaenh/rsaenh.c
+++ b/dlls/rsaenh/rsaenh.c
@@ -2731,11 +2731,27 @@ static BOOL import_private_key(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
         return FALSE;
     }
 
-    if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY)) ||
-        (pRSAPubKey->magic != RSAENH_MAGIC_RSA2) ||
-        (dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
+    if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY)))
+    {
+        ERR("datalen %d not long enough for a BLOBHEADER + RSAPUBKEY\n",
+            dwDataLen);
+        SetLastError(NTE_BAD_DATA);
+        return FALSE;
+    }
+    if (pRSAPubKey->magic != RSAENH_MAGIC_RSA2)
+    {
+        ERR("unexpected magic %08x\n", pRSAPubKey->magic);
+        SetLastError(NTE_BAD_DATA);
+        return FALSE;
+    }
+    if ((dwDataLen < sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
             (2 * pRSAPubKey->bitlen >> 3) + (5 * ((pRSAPubKey->bitlen+8)>>4))))
     {
+        DWORD expectedLen = sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
+            (2 * pRSAPubKey->bitlen >> 3) + (5 * ((pRSAPubKey->bitlen+8)>>4));
+
+        ERR("blob too short for pub key: expect %d, got %d\n",
+            expectedLen, dwDataLen);
         SetLastError(NTE_BAD_DATA);
         return FALSE;
     }




More information about the wine-cvs mailing list