Donat Enikeev : crypt32/tests: Fix regression on Win7 with unprivileged run.

Alexandre Julliard julliard at winehq.org
Tue Nov 15 17:56:15 CST 2016


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

Author: Donat Enikeev <donat at enikeev.net>
Date:   Tue Nov 15 00:18:26 2016 +0300

crypt32/tests: Fix regression on Win7 with unprivileged run.

Signed-off-by: Donat Enikeev <donat at enikeev.net>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/crypt32/tests/store.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c
index 03fc927..132a9da 100644
--- a/dlls/crypt32/tests/store.c
+++ b/dlls/crypt32/tests/store.c
@@ -415,7 +415,15 @@ static void testRegStoreSavedCerts(void)
         cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
         ok (cert1 != NULL, "Create cert context failed at %d, %x\n", i, GetLastError());
         ret = CertAddCertificateContextToStore(store, cert1, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
-        ok (ret, "Adding to the store failed at %d, %x\n", i, GetLastError());
+        /* Addittional skip per Win7, it allows opening HKLM store, but disallows adding certs */
+        err = GetLastError();
+        if (!ret)
+        {
+            ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %d (%08x)\n", i, err);
+            skip("Insufficient privileges for the test %d\n", i);
+            continue;
+        }
+        ok (ret, "Adding to the store failed at %d, %x\n", i, err);
         CertFreeCertificateContext(cert1);
         CertCloseStore(store, 0);
 
@@ -1517,7 +1525,7 @@ static void testFileStore(void)
 
     if (!GetTempFileNameW(szDot, szPrefix, 0, filename))
        return;
- 
+
     DeleteFileW(filename);
     file = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
      CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -2430,12 +2438,12 @@ static void testAddSerialized(void)
     ok(!ret && GetLastError() == E_INVALIDARG,
      "Expected E_INVALIDARG, got %08x\n", GetLastError());
     /* With a bad context type */
-    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 
+    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
      CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
      "Expected E_INVALIDARG, got %08x\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
-     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 
+     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
      CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
      "Expected E_INVALIDARG, got %08x\n", GetLastError());
@@ -2446,12 +2454,12 @@ static void testAddSerialized(void)
      "Expected E_INVALIDARG, got %08x\n", GetLastError());
     /* Bad unknown field, good type */
     hdr->unknown1 = 2;
-    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 
+    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
      "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
-     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 
+     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
      "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError());
@@ -2463,11 +2471,11 @@ static void testAddSerialized(void)
     /* Most everything okay, but bad add disposition */
     hdr->unknown1 = 1;
     /* This crashes
-    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 
+    ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
      * as does this
     ret = CertAddSerializedElementToStore(store, buf,
-     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 
+     sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
      */
     /* Everything okay, but buffer's too big */




More information about the wine-cvs mailing list