Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/crypt32/tests/base64.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/dlls/crypt32/tests/base64.c b/dlls/crypt32/tests/base64.c index 2e7e488..5329c6d 100644 --- a/dlls/crypt32/tests/base64.c +++ b/dlls/crypt32/tests/base64.c @@ -25,6 +25,7 @@ #include <winerror.h> #include <wincrypt.h>
+#include "wine/heap.h" #include "wine/test.h"
#define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n" @@ -47,6 +48,8 @@ static BOOL (WINAPI *pCryptBinaryToStringA)(const BYTE *pbBinary, static BOOL (WINAPI *pCryptStringToBinaryA)(LPCSTR pszString, DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags); +static BOOL (WINAPI *pCryptBinaryToStringW)(const BYTE *pbBinary, + DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString); static BOOL (WINAPI *pCryptStringToBinaryW)(LPCWSTR pszString, DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags); @@ -552,12 +555,34 @@ static void testStringToBinaryA(void) } }
+static void testBinaryToStringW(void) +{ + BYTE *data; + int size = 16656; + DWORD out = 0; + BOOL ret; + + if (!pCryptBinaryToStringW) + { + win_skip("CryptBinaryToStringW is not available\n"); + return; + } + + data = heap_alloc_zero(size); + ret = pCryptBinaryToStringW(data, size, CRYPT_STRING_BASE64, NULL, &out); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + todo_wine ok(out == 22903, "return size returned: %d\n", out); + + heap_free(data); +} + START_TEST(base64) { HMODULE lib = GetModuleHandleA("crypt32");
pCryptBinaryToStringA = (void *)GetProcAddress(lib, "CryptBinaryToStringA"); pCryptStringToBinaryA = (void *)GetProcAddress(lib, "CryptStringToBinaryA"); + pCryptBinaryToStringW = (void *)GetProcAddress(lib, "CryptBinaryToStringW"); pCryptStringToBinaryW = (void *)GetProcAddress(lib, "CryptStringToBinaryW");
if (pCryptBinaryToStringA) @@ -569,4 +594,6 @@ START_TEST(base64) testStringToBinaryA(); else win_skip("CryptStringToBinaryA is not available\n"); + + testBinaryToStringW(); }
On 2/23/2018 6:36 AM, Alistair Leslie-Hughes wrote:
+static void testBinaryToStringW(void) +{
- BYTE *data;
- int size = 16656;
Why this size? Is it reproducible with smaller buffer?
- DWORD out = 0;
- BOOL ret;
- if (!pCryptBinaryToStringW)
- {
win_skip("CryptBinaryToStringW is not available\n");
return;
- }
You don't need that, it's available on all testbot VMs.
- data = heap_alloc_zero(size);
- ret = pCryptBinaryToStringW(data, size, CRYPT_STRING_BASE64, NULL, &out);
- ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
- todo_wine ok(out == 22903, "return size returned: %d\n", out);
- heap_free(data);
I think this should test actual output, matching length alone is not enough.
Hi Nikolay,
18 6:36 AM, Alistair Leslie-Hughes wrote:
- int size = 16656;
Why this size? Is it reproducible with smaller buffer?
This just happens to the size of the image I was embedding into a html file. I had two other images that failure as well and from memory they where bigger. As a test, I subtracted 2 from all the value returned in CryptBinaryToStringW and nothing failed. So, I'm guessing a smaller size would cause the issue as well.
I think this should test actual output, matching length alone is not enough.
Sure, however I don't have a problem with the data itself just the size returned.
Best Regards Alistair.