Wine-Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 84515 discussions
[PATCH v3 1/7] crypt32/tests: Add tests for short return string buffer.
by Paul Gofman April 21, 2022
by Paul Gofman April 21, 2022
April 21, 2022
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
v3:
- fix compiler warning.
dlls/crypt32/tests/str.c | 331 +++++++++++++++------------------------
1 file changed, 127 insertions(+), 204 deletions(-)
diff --git a/dlls/crypt32/tests/str.c b/dlls/crypt32/tests/str.c
index a94381591c0..e10d5a4fb29 100644
--- a/dlls/crypt32/tests/str.c
+++ b/dlls/crypt32/tests/str.c
@@ -429,23 +429,31 @@ static void test_CertNameToStrA(void)
test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a\nb\"", FALSE);
}
-static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
- LPCWSTR expected, BOOL todo)
+#define test_NameToStrConversionW(a, b, c) test_NameToStrConversionW_(__LINE__, a, b, c)
+static void test_NameToStrConversionW_(unsigned int line, PCERT_NAME_BLOB pName, DWORD dwStrType, LPCWSTR expected)
{
- WCHAR buffer[2000] = { 0 };
- DWORD i;
+ DWORD len, retlen, expected_len;
+ WCHAR buffer[2000];
- i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0);
- todo_wine_if (todo)
- ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
- lstrlenW(expected) + 1, i);
- i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer));
- todo_wine_if (todo)
- ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
- lstrlenW(expected) + 1, i);
- todo_wine_if (todo)
- ok(!lstrcmpW(buffer, expected), "Expected %s, got %s\n",
- wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+ expected_len = wcslen(expected) + 1;
+ memset(buffer, 0xcc, sizeof(buffer));
+ len = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, NULL, 0);
+ ok(len == expected_len, "line %u: expected %lu chars, got %lu\n", line, expected_len, len);
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, ARRAY_SIZE(buffer));
+ ok(retlen == len, "line %u: expected %lu chars, got %lu.\n", line, len, retlen);
+ ok(!wcscmp(buffer, expected), "Expected %s, got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+
+ memset(buffer, 0xcc, sizeof(buffer));
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, len - 1);
+ todo_wine ok(retlen == len - 1, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen);
+ ok(!wcsncmp(buffer, expected, retlen - 1), "line %u: expected %s, got %s\n",
+ line, wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+ ok(!buffer[retlen - 1], "line %u: string is not zero terminated.\n", line);
+
+ memset(buffer, 0xcc, sizeof(buffer));
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, 0);
+ todo_wine ok(retlen == len, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen);
+ ok(buffer[0] == 0xcccc, "line %u: got %s\n", line, wine_dbgstr_w(buffer));
}
static void test_CertNameToStrW(void)
@@ -479,95 +487,79 @@ static void test_CertNameToStrW(void)
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR,
- L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric(a)codeweavers.com", FALSE);
+ L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
- L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric(a)codeweavers.com", FALSE);
+ L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
- L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric(a)codeweavers.com",
- FALSE);
+ L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR,
L"2.5.4.6=US, 2.5.4.8=Minnesota, 2.5.4.7=Minneapolis, 2.5.4.10=CodeWeavers, 2.5.4.11=Wine Development,"
- " 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric(a)codeweavers.com", FALSE);
+ " 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
L"2.5.4.6=US; 2.5.4.8=Minnesota; 2.5.4.7=Minneapolis; 2.5.4.10=CodeWeavers; 2.5.4.11=Wine Development;"
- " 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric(a)codeweavers.com", FALSE);
+ " 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
L"2.5.4.6=US\r\n2.5.4.8=Minnesota\r\n2.5.4.7=Minneapolis\r\n2.5.4.10=CodeWeavers\r\n2.5.4.11=Wine "
- "Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric(a)codeweavers…", FALSE);
+ "Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric(a)codeweavers…");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG,
L"E=aric(a)codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; "
- "C=US", FALSE);
+ "C=US");
CertFreeCertificateContext(context);
}
blob.pbData = encodedSimpleCN;
blob.cbData = sizeof(encodedSimpleCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1");
blob.pbData = encodedSingleQuotedCN;
blob.cbData = sizeof(encodedSingleQuotedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"'1'", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"'1'");
blob.pbData = encodedSpacedCN;
blob.cbData = sizeof(encodedSpacedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\" 1 \"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\" 1 \"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\" 1 \"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\" 1 \"");
blob.pbData = encodedQuotedCN;
blob.cbData = sizeof(encodedQuotedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"\"\"1\"\"\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"\"\"1\"\"\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"\"\"1\"\"\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"\"\"1\"\"\"");
blob.pbData = encodedMultipleAttrCN;
blob.cbData = sizeof(encodedMultipleAttrCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"1+2\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"\"1+2\"", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"1+2\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"1+2\"");
blob.pbData = encodedCommaCN;
blob.cbData = sizeof(encodedCommaCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a,b\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a,b\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a,b\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a,b\"");
blob.pbData = encodedEqualCN;
blob.cbData = sizeof(encodedEqualCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a=b\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a=b\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a=b\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a=b\"");
blob.pbData = encodedLessThanCN;
blob.cbData = sizeof(encodedLessThanCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"<\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"<\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"<\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"<\"");
blob.pbData = encodedGreaterThanCN;
blob.cbData = sizeof(encodedGreaterThanCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\">\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"\">\"", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\">\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\">\"");
blob.pbData = encodedHashCN;
blob.cbData = sizeof(encodedHashCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"#\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"#\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"#\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"#\"");
blob.pbData = encodedSemiCN;
blob.cbData = sizeof(encodedSemiCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\";\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\";\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\";\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\";\"");
blob.pbData = encodedNewlineCN;
blob.cbData = sizeof(encodedNewlineCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a\nb\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a\nb\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a\nb\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a\nb\"");
}
struct StrToNameA
@@ -747,153 +739,84 @@ static void test_CertStrToNameW(void)
}
}
-static void test_CertGetNameStringA(void)
+#define test_CertGetNameString_value(a, b, c, d) test_CertGetNameString_value_(__LINE__, a, b, c, d)
+static void test_CertGetNameString_value_(unsigned int line, PCCERT_CONTEXT context, DWORD type, void *type_para,
+ const char *expected)
+{
+ WCHAR expectedW[512];
+ DWORD len, retlen;
+ WCHAR strW[512];
+ unsigned int i;
+ char str[512];
+
+ for (i = 0; expected[i]; ++i)
+ expectedW[i] = expected[i];
+ expectedW[i] = 0;
+
+ len = CertGetNameStringA(context, type, 0, type_para, NULL, 0);
+ ok(len == strlen(expected) + 1, "line %u: unexpected length %ld.\n", line, len);
+ retlen = CertGetNameStringA(context, type, 0, type_para, str, len);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len);
+ ok(!strcmp(str, expected), "line %u: unexpected value %s.\n", line, str);
+ str[0] = str[1] = 0xcc;
+ retlen = CertGetNameStringA(context, type, 0, type_para, str, len - 1);
+ todo_wine ok(retlen == 1, "line %u: Unexpected len %lu, expected 1.\n", line, retlen);
+ todo_wine ok(!str[0], "line %u: unexpected str[0] %#x.\n", line, str[0]);
+ ok(str[1] == expected[1], "line %u: unexpected str[1] %#x.\n", line, str[1]);
+ retlen = CertGetNameStringW(context, type, 0, type_para, strW, len);
+ ok(retlen == len, "line %u: unexpected len %lu, expected 1.\n", line, retlen);
+ ok(!wcscmp(strW, expectedW), "line %u: unexpected value %s.\n", line, debugstr_w(strW));
+ strW[0] = strW[1] = 0xcccc;
+ retlen = CertGetNameStringW(context, type, 0, type_para, strW, len - 1);
+ todo_wine ok(retlen == len - 1, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len - 1);
+ ok(!wcsncmp(strW, expectedW, retlen - 1), "line %u: string data mismatch.\n", line);
+ ok(!strW[retlen - 1], "line %u: string is not zero terminated.\n", line);
+ retlen = CertGetNameStringA(context, type, 0, type_para, NULL, len - 1);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len);
+ retlen = CertGetNameStringW(context, type, 0, type_para, NULL, len - 1);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len);
+}
+
+static void test_CertGetNameString(void)
{
+ static const char aric[] = "aric(a)codeweavers.com";
+ static const char localhost[] = "localhost";
PCCERT_CONTEXT context;
+ DWORD len, type;
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
- ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
- GetLastError());
- if (context)
- {
- static const char aric[] = "aric(a)codeweavers.com";
- static const char localhost[] = "localhost";
- DWORD len, type;
- LPSTR str;
-
- /* Bad string types/types missing from the cert */
- len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
- ok(len == 1, "expected 1, got %ld\n", len);
- len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0);
- ok(len == 1, "expected 1, got %ld\n", len);
- len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL,
- 0);
- ok(len == 1, "expected 1, got %ld\n", len);
-
- len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- type = 0;
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
- 0);
- ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
- str, len);
- ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- type = CERT_OID_NAME_STR;
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
- 0);
- ok(len == strlen(subjectStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
- str, len);
- ok(!strcmp(str, subjectStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_RSA_emailAddr, NULL, 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_RSA_emailAddr, str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_COMMON_NAME, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_COMMON_NAME, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
- NULL, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE,
- 0, NULL, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0,
- NULL, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE,
- 0, NULL, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- if (len > 1)
- {
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- }
-
- CertFreeCertificateContext(context);
- }
+ ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError());
+
+ /* Bad string types/types missing from the cert */
+ len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+
+ len = CertGetNameStringW(NULL, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringW(context, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringW(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+
+ test_CertGetNameString_value(context, CERT_NAME_EMAIL_TYPE, NULL, aric);
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, NULL, issuerStr);
+ type = 0;
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, &type, issuerStr);
+ type = CERT_OID_NAME_STR;
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, &type, subjectStr);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, NULL, aric);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, (void *)szOID_RSA_emailAddr, aric);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, (void *)szOID_COMMON_NAME, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, NULL, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, NULL, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, NULL, localhost);
+
+ CertFreeCertificateContext(context);
}
START_TEST(str)
@@ -904,5 +827,5 @@ START_TEST(str)
test_CertNameToStrW();
test_CertStrToNameA();
test_CertStrToNameW();
- test_CertGetNameStringA();
+ test_CertGetNameString();
}
--
2.35.1
1
6
[PATCH v5 1/8] msvcr100: Add _StructuredTaskCollection::_Schedule stub.
by Torge Matthies April 21, 2022
by Torge Matthies April 21, 2022
April 21, 2022
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47375
Signed-off-by: Torge Matthies <tmatthies(a)codeweavers.com>
---
v4 -> v5:
Changed the spec file entries for i386/arm in addition to win64.
dlls/concrt140/concrt140.spec | 6 +++---
dlls/msvcr100/msvcr100.spec | 4 ++--
dlls/msvcr110/msvcr110.spec | 6 +++---
dlls/msvcr120/msvcr120.spec | 6 +++---
dlls/msvcr120_app/msvcr120_app.spec | 6 +++---
dlls/msvcrt/concurrency.c | 27 +++++++++++++++++++++++++++
6 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/dlls/concrt140/concrt140.spec b/dlls/concrt140/concrt140.spec
index 50db9348327..6bb95661dd1 100644
--- a/dlls/concrt140/concrt140.spec
+++ b/dlls/concrt140/concrt140.spec
@@ -594,9 +594,9 @@
@ stub -arch=arm ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAA?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=i386 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAG?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
-@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@PEAVlocation(a)3@@Z
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 19b4cbe96d7..2a03df03e33 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -363,8 +363,8 @@
@ stub -arch=win64 ?_RunAndWait(a)_StructuredTaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
@ stub -arch=win32 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAG?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win32 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=win32 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
@ stub -arch=win32 ?_Schedule(a)_TaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_Schedule(a)_TaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
@ thiscall -arch=win32 ?_SetSpinCount@?$_SpinWait@$00(a)details@Concurrency@@QAEXI(a)Z(ptr long) SpinWait__SetSpinCount
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 23840f85eda..2888bd97e00 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -614,9 +614,9 @@
@ stub -arch=arm ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAA?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=i386 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAG?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
-@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@PEAVlocation(a)3@@Z
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 64ddeed42f4..8ddc09bcaf8 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -596,9 +596,9 @@
@ stub -arch=arm ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAA?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=i386 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAG?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
-@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
+@ thiscall -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z(ptr ptr) StructuredTaskCollection__Schedule
@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@PEAVlocation(a)3@@Z
diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec
index 05f408d6884..4eb7cb6a298 100644
--- a/dlls/msvcr120_app/msvcr120_app.spec
+++ b/dlls/msvcr120_app/msvcr120_app.spec
@@ -592,9 +592,9 @@
@ stub -arch=arm ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAA?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=i386 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QAG?AW4_TaskCollectionStatus(a)23@PAV_UnrealizedChore(a)23@@Z
@ stub -arch=win64 ?_RunAndWait(a)_TaskCollection@details(a)Concurrency@@QEAA?AW4_TaskCollectionStatus(a)23@PEAV_UnrealizedChore(a)23@@Z
-@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
-@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z(ptr ptr) msvcr120.?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z(ptr ptr) msvcr120.?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z
+@ thiscall -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z(ptr ptr) msvcr120.?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z
@ stub -arch=arm ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=i386 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@PAVlocation(a)3@@Z
@ stub -arch=win64 ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@PEAVlocation(a)3@@Z
diff --git a/dlls/msvcrt/concurrency.c b/dlls/msvcrt/concurrency.c
index 2ca6421b0e7..db6e34ad457 100644
--- a/dlls/msvcrt/concurrency.c
+++ b/dlls/msvcrt/concurrency.c
@@ -174,6 +174,20 @@ typedef struct cs_queue
#endif
} cs_queue;
+#if _MSVCR_VER >= 100
+
+typedef struct
+{
+ char dummy;
+} UnrealizedChore;
+
+typedef struct
+{
+ char dummy;
+} StructuredTaskCollection;
+
+#endif /* _MSVCR_VER >= 100 */
+
typedef struct
{
ULONG_PTR unk_thread_id;
@@ -1741,6 +1755,19 @@ bool __thiscall SpinWait__SpinOnce(SpinWait *this)
}
}
+#if _MSVCR_VER >= 100
+
+/* ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAAXPAV_UnrealizedChore(a)23@@Z */
+/* ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QAEXPAV_UnrealizedChore(a)23@@Z */
+/* ?_Schedule(a)_StructuredTaskCollection@details(a)Concurrency@@QEAAXPEAV_UnrealizedChore(a)23@@Z */
+DEFINE_THISCALL_WRAPPER(StructuredTaskCollection__Schedule, 8)
+void __thiscall StructuredTaskCollection__Schedule(StructuredTaskCollection *this, UnrealizedChore *chore)
+{
+ FIXME("(%p %p): stub!\n", this, chore);
+}
+
+#endif /* _MSVCR_VER >= 100 */
+
/* ??0critical_section(a)Concurrency@@QAE(a)XZ */
/* ??0critical_section(a)Concurrency@@QEAA(a)XZ */
DEFINE_THISCALL_WRAPPER(critical_section_ctor, 4)
--
2.36.0
3
11
[PATCH v4 1/6] user.exe: Implement SetSystemTimer() using SetTimer().
by Zebediah Figura April 21, 2022
by Zebediah Figura April 21, 2022
April 21, 2022
Avoid using SetSystemTimer() to specify a callback; it does not support one.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
v3: Actually call the window procedure...
v4: Rebase.
dlls/user.exe16/message.c | 5 +++++
dlls/user.exe16/user_private.h | 2 ++
dlls/user.exe16/window.c | 4 ++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c
index 819d9d9b837..46561d722ed 100644
--- a/dlls/user.exe16/message.c
+++ b/dlls/user.exe16/message.c
@@ -1292,6 +1292,11 @@ LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT
lParam = MAKELPARAM( 0, convert_handle_32_to_16( lParam, GMEM_DDESHARE ));
ret = callback( HWND_16(hwnd), msg, wParam, lParam, result, arg );
break; /* FIXME don't know how to free allocated memory (handle) !! */
+ case WM_TIMER:
+ if (wParam & SYSTEM_TIMER_FLAG)
+ msg = WM_SYSTIMER;
+ ret = callback( HWND_16(hwnd), msg, wParam, lParam, result, arg );
+ break;
case SBM_SETRANGE:
ret = callback( HWND_16(hwnd), SBM_SETRANGE16, 0, MAKELPARAM(wParam, lParam), result, arg );
break;
diff --git a/dlls/user.exe16/user_private.h b/dlls/user.exe16/user_private.h
index 8a325cf9fb2..0805997246b 100644
--- a/dlls/user.exe16/user_private.h
+++ b/dlls/user.exe16/user_private.h
@@ -95,6 +95,8 @@ extern void call_WH_CALLWNDPROC_hook( HWND16 hwnd, UINT16 msg, WPARAM16 wp, LPAR
#define WM_SYSTIMER 0x0118
+#define SYSTEM_TIMER_FLAG 0x10000
+
/* Dialog info structure (must match the user32 one) */
typedef struct tagDIALOGINFO
{
diff --git a/dlls/user.exe16/window.c b/dlls/user.exe16/window.c
index 590b8ae9f7c..e54dd6a803e 100644
--- a/dlls/user.exe16/window.c
+++ b/dlls/user.exe16/window.c
@@ -111,7 +111,7 @@ UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 pr
UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
{
TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
- return SetSystemTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
+ return SetTimer( WIN_Handle32(hwnd), (UINT_PTR)id | SYSTEM_TIMER_FLAG, timeout, proc32 );
}
@@ -1087,7 +1087,7 @@ void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
*/
BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
{
- return KillSystemTimer( WIN_Handle32(hwnd), id );
+ return KillTimer( WIN_Handle32(hwnd), (UINT_PTR)id | SYSTEM_TIMER_FLAG );
}
--
2.35.1
3
12
[PATCH v2 1/7] crypt32/tests: Add tests for short return string buffer.
by Paul Gofman April 21, 2022
by Paul Gofman April 21, 2022
April 21, 2022
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
dlls/crypt32/tests/str.c | 332 +++++++++++++++------------------------
1 file changed, 127 insertions(+), 205 deletions(-)
diff --git a/dlls/crypt32/tests/str.c b/dlls/crypt32/tests/str.c
index a94381591c0..c91a27a0995 100644
--- a/dlls/crypt32/tests/str.c
+++ b/dlls/crypt32/tests/str.c
@@ -429,23 +429,30 @@ static void test_CertNameToStrA(void)
test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a\nb\"", FALSE);
}
-static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
- LPCWSTR expected, BOOL todo)
+#define test_NameToStrConversionW(a, b, c) test_NameToStrConversionW_(__LINE__, a, b, c)
+static void test_NameToStrConversionW_(unsigned int line, PCERT_NAME_BLOB pName, DWORD dwStrType, LPCWSTR expected)
{
- WCHAR buffer[2000] = { 0 };
- DWORD i;
-
- i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0);
- todo_wine_if (todo)
- ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
- lstrlenW(expected) + 1, i);
- i = CertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer));
- todo_wine_if (todo)
- ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
- lstrlenW(expected) + 1, i);
- todo_wine_if (todo)
- ok(!lstrcmpW(buffer, expected), "Expected %s, got %s\n",
- wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+ WCHAR buffer[2000];
+ DWORD len, retlen;
+
+ memset(buffer, 0xcc, sizeof(buffer));
+ len = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, NULL, 0);
+ ok(len == wcslen(expected) + 1, "line %u: expected %u chars, got %lu\n", line, wcslen(expected) + 1, len);
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, ARRAY_SIZE(buffer));
+ ok(retlen == len, "line %u: expected %lu chars, got %lu.\n", line, len, retlen);
+ ok(!wcscmp(buffer, expected), "Expected %s, got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+
+ memset(buffer, 0xcc, sizeof(buffer));
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, len - 1);
+ todo_wine ok(retlen == len - 1, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen);
+ ok(!wcsncmp(buffer, expected, retlen - 1), "line %u: expected %s, got %s\n",
+ line, wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
+ ok(!buffer[retlen - 1], "line %u: string is not zero terminated.\n", line);
+
+ memset(buffer, 0xcc, sizeof(buffer));
+ retlen = CertNameToStrW(X509_ASN_ENCODING, pName, dwStrType, buffer, 0);
+ todo_wine ok(retlen == len, "line %u: expected %lu chars, got %lu\n", line, len - 1, retlen);
+ ok(buffer[0] == 0xcccc, "line %u: got %s\n", line, wine_dbgstr_w(buffer));
}
static void test_CertNameToStrW(void)
@@ -479,95 +486,79 @@ static void test_CertNameToStrW(void)
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR,
- L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric(a)codeweavers.com", FALSE);
+ L"US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
- L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric(a)codeweavers.com", FALSE);
+ L"US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Issuer,
CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
- L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric(a)codeweavers.com",
- FALSE);
+ L"US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR,
L"2.5.4.6=US, 2.5.4.8=Minnesota, 2.5.4.7=Minneapolis, 2.5.4.10=CodeWeavers, 2.5.4.11=Wine Development,"
- " 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric(a)codeweavers.com", FALSE);
+ " 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
L"2.5.4.6=US; 2.5.4.8=Minnesota; 2.5.4.7=Minneapolis; 2.5.4.10=CodeWeavers; 2.5.4.11=Wine Development;"
- " 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric(a)codeweavers.com", FALSE);
+ " 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric(a)codeweavers.com");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
L"2.5.4.6=US\r\n2.5.4.8=Minnesota\r\n2.5.4.7=Minneapolis\r\n2.5.4.10=CodeWeavers\r\n2.5.4.11=Wine "
- "Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric(a)codeweavers…", FALSE);
+ "Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric(a)codeweavers…");
test_NameToStrConversionW(&context->pCertInfo->Subject,
CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG,
L"E=aric(a)codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; "
- "C=US", FALSE);
+ "C=US");
CertFreeCertificateContext(context);
}
blob.pbData = encodedSimpleCN;
blob.cbData = sizeof(encodedSimpleCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=1");
blob.pbData = encodedSingleQuotedCN;
blob.cbData = sizeof(encodedSingleQuotedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"'1'", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN='1'");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"'1'");
blob.pbData = encodedSpacedCN;
blob.cbData = sizeof(encodedSpacedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\" 1 \"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\" 1 \"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\" 1 \"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\" 1 \"");
blob.pbData = encodedQuotedCN;
blob.cbData = sizeof(encodedQuotedCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"\"\"1\"\"\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"\"\"1\"\"\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"\"\"1\"\"\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"\"\"1\"\"\"");
blob.pbData = encodedMultipleAttrCN;
blob.cbData = sizeof(encodedMultipleAttrCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"1+2\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"\"1+2\"", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"1+2\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"1+2\"");
blob.pbData = encodedCommaCN;
blob.cbData = sizeof(encodedCommaCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a,b\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a,b\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a,b\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a,b\"");
blob.pbData = encodedEqualCN;
blob.cbData = sizeof(encodedEqualCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a=b\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a=b\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a=b\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a=b\"");
blob.pbData = encodedLessThanCN;
blob.cbData = sizeof(encodedLessThanCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"<\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"<\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"<\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"<\"");
blob.pbData = encodedGreaterThanCN;
blob.cbData = sizeof(encodedGreaterThanCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\">\"",
- FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
- L"\">\"", FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\">\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\">\"");
blob.pbData = encodedHashCN;
blob.cbData = sizeof(encodedHashCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"#\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"#\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"#\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"#\"");
blob.pbData = encodedSemiCN;
blob.cbData = sizeof(encodedSemiCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\";\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\";\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\";\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\";\"");
blob.pbData = encodedNewlineCN;
blob.cbData = sizeof(encodedNewlineCN);
- test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a\nb\"", FALSE);
- test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a\nb\"",
- FALSE);
+ test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, L"CN=\"a\nb\"");
+ test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, L"\"a\nb\"");
}
struct StrToNameA
@@ -747,153 +738,84 @@ static void test_CertStrToNameW(void)
}
}
-static void test_CertGetNameStringA(void)
+#define test_CertGetNameString_value(a, b, c, d) test_CertGetNameString_value_(__LINE__, a, b, c, d)
+static void test_CertGetNameString_value_(unsigned int line, PCCERT_CONTEXT context, DWORD type, void *type_para,
+ const char *expected)
+{
+ WCHAR expectedW[512];
+ DWORD len, retlen;
+ WCHAR strW[512];
+ unsigned int i;
+ char str[512];
+
+ for (i = 0; expected[i]; ++i)
+ expectedW[i] = expected[i];
+ expectedW[i] = 0;
+
+ len = CertGetNameStringA(context, type, 0, type_para, NULL, 0);
+ ok(len == strlen(expected) + 1, "line %u: unexpected length %ld.\n", line, len);
+ retlen = CertGetNameStringA(context, type, 0, type_para, str, len);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len);
+ ok(!strcmp(str, expected), "line %u: unexpected value %s.\n", line, str);
+ str[0] = str[1] = 0xcc;
+ retlen = CertGetNameStringA(context, type, 0, type_para, str, len - 1);
+ todo_wine ok(retlen == 1, "line %u: Unexpected len %lu, expected 1.\n", line, retlen);
+ todo_wine ok(!str[0], "line %u: unexpected str[0] %#x.\n", line, str[0]);
+ ok(str[1] == expected[1], "line %u: unexpected str[1] %#x.\n", line, str[1]);
+ retlen = CertGetNameStringW(context, type, 0, type_para, strW, len);
+ ok(retlen == len, "line %u: unexpected len %lu, expected 1.\n", line, retlen);
+ ok(!wcscmp(strW, expectedW), "line %u: unexpected value %s.\n", line, debugstr_w(strW));
+ strW[0] = strW[1] = 0xcccc;
+ retlen = CertGetNameStringW(context, type, 0, type_para, strW, len - 1);
+ todo_wine ok(retlen == len - 1, "line %u: unexpected len %lu, expected %lu.\n", line, retlen, len - 1);
+ ok(!wcsncmp(strW, expectedW, retlen - 1), "line %u: string data mismatch.\n", line);
+ ok(!strW[retlen - 1], "line %u: string is not zero terminated.\n", line);
+ retlen = CertGetNameStringA(context, type, 0, type_para, NULL, len - 1);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len);
+ retlen = CertGetNameStringW(context, type, 0, type_para, NULL, len - 1);
+ ok(retlen == len, "line %u: unexpected len %lu, expected %lu\n", line, retlen, len);
+}
+
+static void test_CertGetNameString(void)
{
+ static const char aric[] = "aric(a)codeweavers.com";
+ static const char localhost[] = "localhost";
PCCERT_CONTEXT context;
+ DWORD len, type;
context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
sizeof(cert));
- ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
- GetLastError());
- if (context)
- {
- static const char aric[] = "aric(a)codeweavers.com";
- static const char localhost[] = "localhost";
- DWORD len, type;
- LPSTR str;
-
- /* Bad string types/types missing from the cert */
- len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
- ok(len == 1, "expected 1, got %ld\n", len);
- len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0);
- ok(len == 1, "expected 1, got %ld\n", len);
- len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL,
- 0);
- ok(len == 1, "expected 1, got %ld\n", len);
-
- len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- type = 0;
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
- 0);
- ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
- str, len);
- ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- type = CERT_OID_NAME_STR;
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
- 0);
- ok(len == strlen(subjectStr) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
- str, len);
- ok(!strcmp(str, subjectStr), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_RSA_emailAddr, NULL, 0);
- ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_RSA_emailAddr, str, len);
- ok(!strcmp(str, aric), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_COMMON_NAME, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
- (void *)szOID_COMMON_NAME, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
- NULL, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE,
- 0, NULL, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0,
- NULL, NULL, 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE,
- 0, NULL, str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
-
- len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL,
- 0);
- ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
- if (len > 1)
- {
- str = HeapAlloc(GetProcessHeap(), 0, len);
- if (str)
- {
- len = CertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL,
- str, len);
- ok(!strcmp(str, localhost), "unexpected value %s\n", str);
- HeapFree(GetProcessHeap(), 0, str);
- }
- }
-
- CertFreeCertificateContext(context);
- }
+ ok(!!context, "CertCreateCertificateContext failed, err %lu\n", GetLastError());
+
+ /* Bad string types/types missing from the cert */
+ len = CertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringA(context, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+
+ len = CertGetNameStringW(NULL, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringW(context, 0, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+ len = CertGetNameStringW(context, CERT_NAME_URL_TYPE, 0, NULL, NULL, 0);
+ ok(len == 1, "expected 1, got %lu\n", len);
+
+ test_CertGetNameString_value(context, CERT_NAME_EMAIL_TYPE, NULL, aric);
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, NULL, issuerStr);
+ type = 0;
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, &type, issuerStr);
+ type = CERT_OID_NAME_STR;
+ test_CertGetNameString_value(context, CERT_NAME_RDN_TYPE, &type, subjectStr);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, NULL, aric);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, (void *)szOID_RSA_emailAddr, aric);
+ test_CertGetNameString_value(context, CERT_NAME_ATTR_TYPE, (void *)szOID_COMMON_NAME, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, NULL, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, NULL, localhost);
+ test_CertGetNameString_value(context, CERT_NAME_DNS_TYPE, NULL, localhost);
+
+ CertFreeCertificateContext(context);
}
START_TEST(str)
@@ -904,5 +826,5 @@ START_TEST(str)
test_CertNameToStrW();
test_CertStrToNameA();
test_CertStrToNameW();
- test_CertGetNameStringA();
+ test_CertGetNameString();
}
--
2.35.1
2
7
[PATCH] kernelbase: Add support for progress callback in CopyFileEx.
by Alistair Leslie-Hughes April 21, 2022
by Alistair Leslie-Hughes April 21, 2022
April 21, 2022
Based on patch by Michael MĂĽller.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/kernel32/tests/file.c | 7 +----
dlls/kernelbase/file.c | 54 +++++++++++++++++++++++++++++++++++---
2 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index 1fb9e98cf41..4f47dd8a51f 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -1176,21 +1176,16 @@ static void test_CopyFileEx(void)
ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
retok = CopyFileExA(source, dest, copy_progress_cb, hfile, NULL, 0);
- todo_wine
ok(!retok, "CopyFileExA unexpectedly succeeded\n");
- todo_wine
ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %ld\n", GetLastError());
ok(GetFileAttributesA(dest) != INVALID_FILE_ATTRIBUTES, "file was deleted\n");
hfile = CreateFileA(dest, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, 0);
- todo_wine
ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
retok = CopyFileExA(source, dest, copy_progress_cb, hfile, NULL, 0);
- todo_wine
ok(!retok, "CopyFileExA unexpectedly succeeded\n");
- todo_wine
ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %ld\n", GetLastError());
todo_wine
ok(GetFileAttributesA(dest) == INVALID_FILE_ATTRIBUTES, "file was not deleted\n");
@@ -1205,7 +1200,7 @@ static void test_CopyFileEx(void)
ret = DeleteFileA(source);
ok(ret, "DeleteFileA failed with error %ld\n", GetLastError());
ret = DeleteFileA(dest);
- ok(!ret, "DeleteFileA unexpectedly succeeded\n");
+ todo_wine ok(!ret, "DeleteFileA unexpectedly succeeded\n");
}
/*
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index 8ae982294f6..6803c79a4a4 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -490,6 +490,23 @@ BOOL WINAPI DECLSPEC_HOTPATCH AreFileApisANSI(void)
return !oem_file_apis;
}
+static DWORD call_progress_dialog(LPPROGRESS_ROUTINE progress, LARGE_INTEGER size, LARGE_INTEGER transferred,
+ DWORD cbtype, HANDLE h1, HANDLE h2, void *param)
+{
+ DWORD cbret;
+
+ cbret = progress( size, transferred, size, transferred, 1, cbtype, h1, h2, param );
+ if (cbret == PROGRESS_STOP)
+ SetLastError( ERROR_REQUEST_ABORTED );
+ else if (cbret == PROGRESS_CANCEL)
+ {
+ BOOLEAN disp = TRUE;
+ SetFileInformationByHandle( h2, FileDispositionInfo, &disp, sizeof(disp) );
+ SetLastError( ERROR_REQUEST_ABORTED );
+ }
+
+ return cbret;
+}
/***********************************************************************
* CopyFileExW (kernelbase.@)
@@ -499,11 +516,14 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
{
static const int buffer_size = 65536;
HANDLE h1, h2;
- FILE_BASIC_INFORMATION info;
+ FILE_NETWORK_OPEN_INFORMATION info;
+ FILE_BASIC_INFORMATION basic_info;
IO_STATUS_BLOCK io;
DWORD count;
BOOL ret = FALSE;
char *buffer;
+ LARGE_INTEGER transferred;
+ DWORD cbret;
if (!source || !dest)
{
@@ -533,7 +553,7 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
return FALSE;
}
- if (!set_ntstatus( NtQueryInformationFile( h1, &io, &info, sizeof(info), FileBasicInformation )))
+ if (!set_ntstatus( NtQueryInformationFile( h1, &io, &info, sizeof(info), FileNetworkOpenInformation )))
{
WARN("GetFileInformationByHandle returned error for %s\n", debugstr_w(source));
HeapFree( GetProcessHeap(), 0, buffer );
@@ -569,6 +589,17 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
return FALSE;
}
+ if (progress)
+ {
+ transferred.QuadPart = 0;
+
+ cbret = call_progress_dialog(progress, info.EndOfFile, transferred, CALLBACK_STREAM_SWITCH, h1, h2, param);
+ if (cbret == PROGRESS_QUIET)
+ progress = NULL;
+ else if (cbret != PROGRESS_CONTINUE)
+ goto done;
+ }
+
while (ReadFile( h1, buffer, buffer_size, &count, NULL ) && count)
{
char *p = buffer;
@@ -578,13 +609,28 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
p += res;
count -= res;
+
+ if (progress)
+ {
+ transferred.QuadPart += res;
+
+ cbret = call_progress_dialog(progress, info.EndOfFile, transferred, CALLBACK_CHUNK_FINISHED, h1, h2, param);
+ if (cbret == PROGRESS_QUIET)
+ progress = NULL;
+ else if (cbret != PROGRESS_CONTINUE)
+ goto done;
+ }
}
}
ret = TRUE;
done:
/* Maintain the timestamp of source file to destination file */
- info.FileAttributes = 0;
- NtSetInformationFile( h2, &io, &info, sizeof(info), FileBasicInformation );
+ basic_info.CreationTime = info.CreationTime;
+ basic_info.LastAccessTime = info.LastAccessTime;
+ basic_info.LastWriteTime = info.LastWriteTime;
+ basic_info.ChangeTime = info.ChangeTime;
+ basic_info.FileAttributes = 0;
+ NtSetInformationFile( h2, &io, &basic_info, sizeof(basic_info), FileBasicInformation );
HeapFree( GetProcessHeap(), 0, buffer );
CloseHandle( h1 );
CloseHandle( h2 );
--
2.35.1
2
1
[PATCH v3 3/3] webservices: Always set channel state to WS_CHANNEL_STATE_FAULTED when a send or receive operation failed.
by Hans Leidekker April 21, 2022
by Hans Leidekker April 21, 2022
April 21, 2022
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 58 ++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 21 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 56ad5692a6b..4c9f9c4ccff 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -1608,6 +1608,7 @@ HRESULT channel_send_message( WS_CHANNEL *handle, WS_MESSAGE *msg )
}
hr = send_message_bytes( channel, msg );
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
LeaveCriticalSection( &channel->cs );
return hr;
@@ -1723,11 +1724,15 @@ static HRESULT send_message( struct channel *channel, WS_MESSAGE *msg, const WS_
WS_WRITE_OPTION option, const void *body, ULONG size )
{
HRESULT hr;
- if ((hr = WsAddressMessage( msg, &channel->addr, NULL )) != S_OK) return hr;
- if ((hr = message_set_action( msg, desc->action )) != S_OK) return hr;
- if ((hr = init_writer( channel )) != S_OK) return hr;
- if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) return hr;
- return send_message_bytes( channel, msg );
+ if ((hr = WsAddressMessage( msg, &channel->addr, NULL )) != S_OK) goto done;
+ if ((hr = message_set_action( msg, desc->action )) != S_OK) goto done;
+ if ((hr = init_writer( channel )) != S_OK) goto done;
+ if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) goto done;
+ hr = send_message_bytes( channel, msg );
+
+done:
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
+ return hr;
}
struct send_message
@@ -2260,11 +2265,7 @@ static HRESULT receive_message_bytes_session( struct channel *channel )
{
ULONG size;
if ((hr = build_dict( (const BYTE *)channel->read_buf, channel->read_size, &channel->dict_recv,
- &size )) != S_OK)
- {
- if (hr == WS_E_QUOTA_EXCEEDED) channel->state = WS_CHANNEL_STATE_FAULTED;
- return hr;
- }
+ &size )) != S_OK) return hr;
channel->read_size -= size;
memmove( channel->read_buf, channel->read_buf + size, channel->read_size );
}
@@ -2328,6 +2329,7 @@ HRESULT channel_receive_message( WS_CHANNEL *handle, WS_MESSAGE *msg )
}
if ((hr = receive_message_bytes( channel, msg )) == S_OK) hr = init_reader( channel );
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
LeaveCriticalSection( &channel->cs );
return hr;
@@ -2367,8 +2369,8 @@ static HRESULT receive_message( struct channel *channel, WS_MESSAGE *msg, const
HRESULT hr;
ULONG i;
- if ((hr = receive_message_bytes( channel, msg )) != S_OK) return hr;
- if ((hr = init_reader( channel )) != S_OK) return hr;
+ if ((hr = receive_message_bytes( channel, msg )) != S_OK) goto done;
+ if ((hr = init_reader( channel )) != S_OK) goto done;
for (i = 0; i < count; i++)
{
@@ -2378,10 +2380,14 @@ static HRESULT receive_message( struct channel *channel, WS_MESSAGE *msg, const
if (index) *index = i;
break;
}
- if ((hr = WsResetMessage( msg, NULL )) != S_OK) return hr;
- if ((hr = init_reader( channel )) != S_OK) return hr;
+ if ((hr = WsResetMessage( msg, NULL )) != S_OK) goto done;
+ if ((hr = init_reader( channel )) != S_OK) goto done;
}
- return (i == count) ? WS_E_INVALID_FORMAT : S_OK;
+ hr = (i == count) ? WS_E_INVALID_FORMAT : S_OK;
+
+done:
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
+ return hr;
}
struct receive_message
@@ -2606,6 +2612,7 @@ static HRESULT read_message_start( struct channel *channel, WS_MESSAGE *msg )
HRESULT hr;
if ((hr = receive_message_bytes( channel, msg )) == S_OK && (hr = init_reader( channel )) == S_OK)
hr = WsReadEnvelopeStart( msg, channel->reader, NULL, NULL, NULL );
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
return hr;
}
@@ -2682,14 +2689,17 @@ HRESULT WINAPI WsReadMessageStart( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
return hr;
}
-static HRESULT read_message_end( WS_MESSAGE *msg )
+static HRESULT read_message_end( struct channel *channel, WS_MESSAGE *msg )
{
- return WsReadEnvelopeEnd( msg, NULL );
+ HRESULT hr = WsReadEnvelopeEnd( msg, NULL );
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
+ return hr;
}
struct read_message_end
{
struct task task;
+ struct channel *channel;
WS_MESSAGE *msg;
WS_ASYNC_CONTEXT ctx;
};
@@ -2699,7 +2709,7 @@ static void read_message_end_proc( struct task *task )
struct read_message_end *r = (struct read_message_end *)task;
HRESULT hr;
- hr = read_message_end( r->msg );
+ hr = read_message_end( r->channel, r->msg );
TRACE( "calling %p(%#lx)\n", r->ctx.callback, hr );
r->ctx.callback( hr, WS_LONG_CALLBACK, r->ctx.callbackState );
@@ -2712,6 +2722,7 @@ static HRESULT queue_read_message_end( struct channel *channel, WS_MESSAGE *msg,
if (!(r = malloc( sizeof(*r) ))) return E_OUTOFMEMORY;
r->task.proc = read_message_end_proc;
+ r->channel = channel;
r->msg = msg;
r->ctx = *ctx;
return queue_task( &channel->recv_q, &r->task );
@@ -2756,9 +2767,13 @@ HRESULT WINAPI WsReadMessageEnd( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_A
static HRESULT write_message_start( struct channel *channel, WS_MESSAGE *msg )
{
HRESULT hr;
- if ((hr = init_writer( channel )) != S_OK) return hr;
- if ((hr = WsAddressMessage( msg, &channel->addr, NULL )) != S_OK) return hr;
- return WsWriteEnvelopeStart( msg, channel->writer, NULL, NULL, NULL );
+ if ((hr = init_writer( channel )) != S_OK) goto done;
+ if ((hr = WsAddressMessage( msg, &channel->addr, NULL )) != S_OK) goto done;
+ hr = WsWriteEnvelopeStart( msg, channel->writer, NULL, NULL, NULL );
+
+done:
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
+ return hr;
}
struct write_message_start
@@ -2838,6 +2853,7 @@ static HRESULT write_message_end( struct channel *channel, WS_MESSAGE *msg )
{
HRESULT hr;
if ((hr = WsWriteEnvelopeEnd( msg, NULL )) == S_OK) hr = send_message_bytes( channel, msg );
+ if (hr != S_OK) channel->state = WS_CHANNEL_STATE_FAULTED;
return hr;
}
--
2.30.2
1
0
[PATCH v3 2/3] webservices: Respect session dictionary size limits on receive dictionary.
by Hans Leidekker April 21, 2022
by Hans Leidekker April 21, 2022
April 21, 2022
From: Connor McAdams <cmcadams(a)codeweavers.com>
v3: Use a helper to check channel state.
Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 66 ++++++++++++++++++++------------
dlls/webservices/tests/channel.c | 17 +++++++-
2 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 7dd78335e11..56ad5692a6b 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -328,7 +328,7 @@ static void reset_channel( struct channel *channel )
channel->session_state = SESSION_STATE_UNINITIALIZED;
clear_addr( &channel->addr );
init_dict( &channel->dict_send, channel->dict_size );
- init_dict( &channel->dict_recv, 0 );
+ init_dict( &channel->dict_recv, channel->dict_size );
channel->msg = NULL;
channel->read_size = 0;
channel->send_size = 0;
@@ -486,6 +486,7 @@ static HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
channel->encoding = WS_ENCODING_XML_BINARY_SESSION_1;
channel->dict_size = 2048;
channel->dict_send.str_bytes_max = channel->dict_size;
+ channel->dict_recv.str_bytes_max = channel->dict_size;
break;
case WS_UDP_CHANNEL_BINDING:
@@ -546,6 +547,7 @@ static HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
channel->dict_size = *(ULONG *)prop->value;
channel->dict_send.str_bytes_max = channel->dict_size;
+ channel->dict_recv.str_bytes_max = channel->dict_size;
break;
default:
@@ -875,6 +877,13 @@ static HRESULT queue_shutdown_session( struct channel *channel, const WS_ASYNC_C
return queue_task( &channel->send_q, &s->task );
}
+static HRESULT check_state( struct channel *channel, WS_CHANNEL_STATE state_expected )
+{
+ if (channel->state == WS_CHANNEL_STATE_FAULTED) return WS_E_OBJECT_FAULTED;
+ if (channel->state != state_expected) return WS_E_INVALID_OPERATION;
+ return S_OK;
+}
+
HRESULT WINAPI WsShutdownSessionChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
{
struct channel *channel = (struct channel *)handle;
@@ -894,10 +903,10 @@ HRESULT WINAPI WsShutdownSessionChannel( WS_CHANNEL *handle, const WS_ASYNC_CONT
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
@@ -1258,10 +1267,10 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_CREATED)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_CREATED )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
@@ -1592,10 +1601,10 @@ HRESULT channel_send_message( WS_CHANNEL *handle, WS_MESSAGE *msg )
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
hr = send_message_bytes( channel, msg );
@@ -1786,10 +1795,10 @@ HRESULT WINAPI WsSendMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_MESS
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
WsInitializeMessage( msg, WS_BLANK_MESSAGE, NULL, NULL );
@@ -1832,10 +1841,10 @@ HRESULT WINAPI WsSendReplyMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
WsInitializeMessage( msg, WS_REPLY_MESSAGE, NULL, NULL );
@@ -2201,6 +2210,11 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
init_dict( dict, 0 );
return WS_E_INVALID_FORMAT;
}
+ if (size + dict->str_bytes + 1 > dict->str_bytes_max)
+ {
+ hr = WS_E_QUOTA_EXCEEDED;
+ goto error;
+ }
buflen -= size;
if (!(bytes = malloc( size )))
{
@@ -2246,7 +2260,11 @@ static HRESULT receive_message_bytes_session( struct channel *channel )
{
ULONG size;
if ((hr = build_dict( (const BYTE *)channel->read_buf, channel->read_size, &channel->dict_recv,
- &size )) != S_OK) return hr;
+ &size )) != S_OK)
+ {
+ if (hr == WS_E_QUOTA_EXCEEDED) channel->state = WS_CHANNEL_STATE_FAULTED;
+ return hr;
+ }
channel->read_size -= size;
memmove( channel->read_buf, channel->read_buf + size, channel->read_size );
}
@@ -2303,10 +2321,10 @@ HRESULT channel_receive_message( WS_CHANNEL *handle, WS_MESSAGE *msg )
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if ((hr = receive_message_bytes( channel, msg )) == S_OK) hr = init_reader( channel );
@@ -2443,10 +2461,10 @@ HRESULT WINAPI WsReceiveMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_M
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
@@ -2561,10 +2579,10 @@ HRESULT WINAPI WsRequestReply( WS_CHANNEL *handle, WS_MESSAGE *request, const WS
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
WsInitializeMessage( request, WS_REQUEST_MESSAGE, NULL, NULL );
@@ -2645,10 +2663,10 @@ HRESULT WINAPI WsReadMessageStart( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
@@ -2797,10 +2815,10 @@ HRESULT WINAPI WsWriteMessageStart( WS_CHANNEL *handle, WS_MESSAGE *msg, const W
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
@@ -2877,10 +2895,10 @@ HRESULT WINAPI WsWriteMessageEnd( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_
LeaveCriticalSection( &channel->cs );
return E_INVALIDARG;
}
- if (channel->state != WS_CHANNEL_STATE_OPEN)
+ if ((hr = check_state( channel, WS_CHANNEL_STATE_OPEN )) != S_OK)
{
LeaveCriticalSection( &channel->cs );
- return WS_E_INVALID_OPERATION;
+ return hr;
}
if (!ctx) async_init( &async, &ctx_local );
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index d5d35904c1c..7e0a9becbc5 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -822,6 +822,7 @@ static void client_duplex_session_dict( const struct listener_info *info )
WS_MESSAGE_DESCRIPTION desc;
WS_ENDPOINT_ADDRESS addr;
WS_CHANNEL_PROPERTY prop;
+ WS_CHANNEL_STATE state;
int dict_str_cnt = 0;
char elem_name[128];
WS_CHANNEL *channel;
@@ -893,12 +894,24 @@ static void client_duplex_session_dict( const struct listener_info *info )
local_name.bytes = (BYTE *)short_dict_str;
hr = WsReceiveMessage( channel, msg, descs, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
NULL, &val, sizeof(val), NULL, NULL, NULL );
- todo_wine ok( hr == WS_E_QUOTA_EXCEEDED, "got %#lx\n", hr);
+ ok( hr == WS_E_QUOTA_EXCEEDED, "got %#lx\n", hr);
+
+ state = 0xdeadbeef;
+ hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, sizeof(state), NULL );
+ ok( hr == S_OK, "got %#lx\n", hr );
+ ok( state == WS_CHANNEL_STATE_FAULTED, "got %u\n", state );
+
+ hr = WsReceiveMessage( channel, msg, descs, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
+ NULL, &val, sizeof(val), NULL, NULL, NULL );
+ ok( hr == WS_E_OBJECT_FAULTED, "got %#lx\n", hr );
+
+ hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
+ ok( hr == WS_E_OBJECT_FAULTED, "got %#lx\n", hr );
WsFreeMessage( msg );
hr = WsShutdownSessionChannel( channel, NULL, NULL );
- todo_wine ok( hr == WS_E_OBJECT_FAULTED, "got %#lx\n", hr );
+ ok( hr == WS_E_OBJECT_FAULTED, "got %#lx\n", hr );
hr = WsCloseChannel( channel, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
--
2.30.2
1
0
[PATCH v3 1/3] webservices: Respect session dictionary size limits on send dictionary.
by Hans Leidekker April 21, 2022
by Hans Leidekker April 21, 2022
April 21, 2022
From: Connor McAdams <cmcadams(a)codeweavers.com>
v3: Warn when maximum size is reached.
Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 21 +++++++++++++++------
dlls/webservices/string.c | 5 ++++-
dlls/webservices/webservices_private.h | 4 +++-
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 4941844afe5..7dd78335e11 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -327,8 +327,8 @@ static void reset_channel( struct channel *channel )
channel->state = WS_CHANNEL_STATE_CREATED;
channel->session_state = SESSION_STATE_UNINITIALIZED;
clear_addr( &channel->addr );
- clear_dict( &channel->dict_send );
- clear_dict( &channel->dict_recv );
+ init_dict( &channel->dict_send, channel->dict_size );
+ init_dict( &channel->dict_recv, 0 );
channel->msg = NULL;
channel->read_size = 0;
channel->send_size = 0;
@@ -485,6 +485,7 @@ static HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
channel->u.tcp.socket = -1;
channel->encoding = WS_ENCODING_XML_BINARY_SESSION_1;
channel->dict_size = 2048;
+ channel->dict_send.str_bytes_max = channel->dict_size;
break;
case WS_UDP_CHANNEL_BINDING:
@@ -544,6 +545,7 @@ static HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
}
channel->dict_size = *(ULONG *)prop->value;
+ channel->dict_send.str_bytes_max = channel->dict_size;
break;
default:
@@ -1615,6 +1617,13 @@ static HRESULT CALLBACK dict_cb( void *state, const WS_XML_STRING *str, BOOL *fo
return S_OK;
}
+ if (str->length + dict->str_bytes + 1 > dict->str_bytes_max)
+ {
+ WARN( "max string bytes exceeded\n" );
+ *found = FALSE;
+ return hr;
+ }
+
if (!(bytes = malloc( str->length ))) return E_OUTOFMEMORY;
memcpy( bytes, str->bytes, str->length );
if ((hr = insert_string( dict, bytes, str->length, index, id )) == S_OK)
@@ -2184,12 +2193,12 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
{
if ((hr = read_size( &ptr, buflen, &size )) != S_OK)
{
- clear_dict( dict );
+ init_dict( dict, 0 );
return hr;
}
if (size > buflen)
{
- clear_dict( dict );
+ init_dict( dict, 0 );
return WS_E_INVALID_FORMAT;
}
buflen -= size;
@@ -2208,7 +2217,7 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
if ((hr = insert_string( dict, bytes, size, index, NULL )) != S_OK)
{
free( bytes );
- clear_dict( dict );
+ init_dict( dict, 0 );
return hr;
}
ptr += size;
@@ -2216,7 +2225,7 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
return S_OK;
error:
- clear_dict( dict );
+ init_dict( dict, 0 );
return hr;
}
diff --git a/dlls/webservices/string.c b/dlls/webservices/string.c
index 3ecdcea85a4..34e67101e66 100644
--- a/dlls/webservices/string.c
+++ b/dlls/webservices/string.c
@@ -131,7 +131,7 @@ static HRESULT grow_dict( struct dictionary *dict, ULONG size )
return S_OK;
}
-void clear_dict( struct dictionary *dict )
+void init_dict( struct dictionary *dict, ULONG str_bytes_max )
{
ULONG i;
assert( !dict->dict.isConst );
@@ -145,6 +145,8 @@ void clear_dict( struct dictionary *dict )
dict->sequence = NULL;
dict->current_sequence = 0;
dict->size = 0;
+ dict->str_bytes = 0;
+ dict->str_bytes_max = str_bytes_max;
}
HRESULT insert_string( struct dictionary *dict, unsigned char *data, ULONG len, int i, ULONG *ret_id )
@@ -162,6 +164,7 @@ HRESULT insert_string( struct dictionary *dict, unsigned char *data, ULONG len,
dict->dict.strings[id].dictionary = &dict->dict;
dict->dict.strings[id].id = id;
dict->dict.stringCount++;
+ dict->str_bytes += len + 1;
dict->sequence[id] = dict->current_sequence;
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index b352aa52d49..373ab6799a9 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -49,13 +49,15 @@ struct dictionary
ULONG size;
ULONG current_sequence;
ULONG *sequence;
+ ULONG str_bytes;
+ ULONG str_bytes_max;
};
extern struct dictionary dict_builtin DECLSPEC_HIDDEN;
extern const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
-void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN;
+void init_dict( struct dictionary *, ULONG ) DECLSPEC_HIDDEN;
HRESULT writer_set_lookup( WS_XML_WRITER *, BOOL ) DECLSPEC_HIDDEN;
HRESULT writer_set_dict_callback( WS_XML_WRITER *, WS_DYNAMIC_STRING_CALLBACK, void * ) DECLSPEC_HIDDEN;
--
2.30.2
1
0
[PATCH 1/5] wined3d: Make loading from WINED3D_LOCATION_CLEARED into a texture op.
by Zebediah Figura April 21, 2022
by Zebediah Figura April 21, 2022
April 21, 2022
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/texture.c | 58 +++++++++++++++++++++++++++-------
dlls/wined3d/wined3d_private.h | 3 ++
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index c495de171d5..18fd0847296 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -816,17 +816,8 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
if (current & WINED3D_LOCATION_CLEARED)
{
- struct wined3d_bo_address addr;
-
- /* FIXME: Clear textures on the GPU if possible. */
-
- if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM))
- return FALSE;
- wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM);
- memset(addr.addr, 0, texture->sub_resources[sub_resource_idx].size);
- wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
- current |= WINED3D_LOCATION_SYSMEM;
-
+ texture->texture_ops->texture_clear(texture, sub_resource_idx, context, location);
+ current = texture->sub_resources[sub_resource_idx].locations;
if (current & location)
return TRUE;
}
@@ -3447,6 +3438,20 @@ static void wined3d_texture_gl_unload_location(struct wined3d_texture *texture,
}
}
+static void wined3d_texture_gl_clear(struct wined3d_texture *texture,
+ unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
+{
+ struct wined3d_bo_address addr;
+
+ TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
+ texture, sub_resource_idx, context, wined3d_debug_location(location));
+
+ wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
+ wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM);
+ memset(addr.addr, 0, texture->sub_resources[sub_resource_idx].size);
+ wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
+}
+
static const struct wined3d_texture_ops texture_gl_ops =
{
wined3d_texture_gl_prepare_location,
@@ -3454,6 +3459,7 @@ static const struct wined3d_texture_ops texture_gl_ops =
wined3d_texture_gl_unload_location,
wined3d_texture_gl_upload_data,
wined3d_texture_gl_download_data,
+ wined3d_texture_gl_clear,
};
struct wined3d_texture * __cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
@@ -4681,6 +4687,20 @@ static void wined3d_texture_no3d_unload_location(struct wined3d_texture *texture
TRACE("texture %p, context %p, location %s.\n", texture, context, wined3d_debug_location(location));
}
+static void wined3d_texture_no3d_clear(struct wined3d_texture *texture,
+ unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
+{
+ struct wined3d_bo_address addr;
+
+ TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
+ texture, sub_resource_idx, context, wined3d_debug_location(location));
+
+ wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
+ wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM);
+ memset(addr.addr, 0, texture->sub_resources[sub_resource_idx].size);
+ wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
+}
+
static const struct wined3d_texture_ops wined3d_texture_no3d_ops =
{
wined3d_texture_no3d_prepare_location,
@@ -4688,6 +4708,7 @@ static const struct wined3d_texture_ops wined3d_texture_no3d_ops =
wined3d_texture_no3d_unload_location,
wined3d_texture_no3d_upload_data,
wined3d_texture_no3d_download_data,
+ wined3d_texture_no3d_clear,
};
HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
@@ -5458,6 +5479,20 @@ static void wined3d_texture_vk_unload_location(struct wined3d_texture *texture,
}
}
+static void wined3d_texture_vk_clear(struct wined3d_texture *texture,
+ unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
+{
+ struct wined3d_bo_address addr;
+
+ TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
+ texture, sub_resource_idx, context, wined3d_debug_location(location));
+
+ wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
+ wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM);
+ memset(addr.addr, 0, texture->sub_resources[sub_resource_idx].size);
+ wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
+}
+
static const struct wined3d_texture_ops wined3d_texture_vk_ops =
{
wined3d_texture_vk_prepare_location,
@@ -5465,6 +5500,7 @@ static const struct wined3d_texture_ops wined3d_texture_vk_ops =
wined3d_texture_vk_unload_location,
wined3d_texture_vk_upload_data,
wined3d_texture_vk_download_data,
+ wined3d_texture_vk_clear,
};
HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 54bccb3db5e..9cfb3a217d2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4393,6 +4393,9 @@ struct wined3d_texture_ops
const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
+ /* "location" is a hint, and need not be the resulting location. */
+ void (*texture_clear)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, unsigned int location);
};
#define WINED3D_TEXTURE_COND_NP2 0x00000001
--
2.35.1
3
9
Required for dxva video playback by Chromium-based
browsers and the Chromium Embedded Framework,
including Adobe Photoshop's tooltip hint videos.
Signed-off-by: Mohamad Al-Jaf <mohamadaljaf(a)gmail.com>
---
configure.ac | 1 +
dlls/msmpeg2vdec/Makefile.in | 6 ++++++
dlls/msmpeg2vdec/main.c | 32 +++++++++++++++++++++++++++++++
dlls/msmpeg2vdec/msmpeg2vdec.spec | 8 ++++++++
4 files changed, 47 insertions(+)
create mode 100644 dlls/msmpeg2vdec/Makefile.in
create mode 100644 dlls/msmpeg2vdec/main.c
create mode 100644 dlls/msmpeg2vdec/msmpeg2vdec.spec
diff --git a/configure.ac b/configure.ac
index 48445cc7b2f..d2e0127f262 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2750,6 +2750,7 @@ WINE_CONFIG_MAKEFILE(dlls/msimtf)
WINE_CONFIG_MAKEFILE(dlls/msisip)
WINE_CONFIG_MAKEFILE(dlls/msisys.ocx)
WINE_CONFIG_MAKEFILE(dlls/msls31)
+WINE_CONFIG_MAKEFILE(dlls/msmpeg2vdec)
WINE_CONFIG_MAKEFILE(dlls/msnet32)
WINE_CONFIG_MAKEFILE(dlls/mspatcha)
WINE_CONFIG_MAKEFILE(dlls/mspatcha/tests)
diff --git a/dlls/msmpeg2vdec/Makefile.in b/dlls/msmpeg2vdec/Makefile.in
new file mode 100644
index 00000000000..54ada2f20c4
--- /dev/null
+++ b/dlls/msmpeg2vdec/Makefile.in
@@ -0,0 +1,6 @@
+MODULE = msmpeg2vdec.dll
+
+EXTRADLLFLAGS = -Wb,--prefer-native
+
+C_SRCS = \
+ main.c
diff --git a/dlls/msmpeg2vdec/main.c b/dlls/msmpeg2vdec/main.c
new file mode 100644
index 00000000000..61ada37b2f6
--- /dev/null
+++ b/dlls/msmpeg2vdec/main.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2022 Mohamad Al-Jaf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msmpeg2vdec);
+
+HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, LPVOID *ppv)
+{
+ FIXME("(%s %s %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv);
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/msmpeg2vdec/msmpeg2vdec.spec b/dlls/msmpeg2vdec/msmpeg2vdec.spec
new file mode 100644
index 00000000000..b81b77ce108
--- /dev/null
+++ b/dlls/msmpeg2vdec/msmpeg2vdec.spec
@@ -0,0 +1,8 @@
+@ stub GetH264DecoderFunctionTable
+@ stub ?GetSurface(a)CVIDEOfilter@@QEAAJHPEAEJ(a)Z
+@ stub ?GetSurfaceSize(a)CVIDEOfilter@@QEAAJHPEAJ(a)Z
+@ stub ?LoadSurface(a)CVIDEOfilter@@QEAAJHPEAEK(a)Z
+@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllGetClassObject(ptr ptr ptr)
+@ stdcall -private DllRegisterServer()
+@ stdcall -private DllUnregisterServer()
--
2.36.0
2
7