Wine-devel
Threads by month
- ----- 2026 -----
- 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
February 2018
- 74 participants
- 746 discussions
[PATCH v3] oleaut32/tests: Mark some tmarshal tests as todo on x64 and ARM
by Alex Henrie 14 Feb '18
by Alex Henrie 14 Feb '18
14 Feb '18
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/oleaut32/tests/tmarshal.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
index 67b8e22642..00cb4646c5 100644
--- a/dlls/oleaut32/tests/tmarshal.c
+++ b/dlls/oleaut32/tests/tmarshal.c
@@ -34,6 +34,12 @@ static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
+#ifdef __i386__
+static const int tmarshal_todo = 0;
+#else
+static const int tmarshal_todo = 1;
+#endif
+
/* ULL suffix is not portable */
#define ULL_CONST(dw1, dw2) ((((ULONGLONG)dw1) << 32) | (ULONGLONG)dw2)
@@ -1305,6 +1311,7 @@ static void test_typelibmarshal(void)
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
hr = CoUnmarshalInterface(pStream, &IID_IKindaEnumWidget, (void **)&pKEW);
+ todo_wine_if(tmarshal_todo)
ok_ole_success(hr, CoUnmarshalInterface);
IStream_Release(pStream);
@@ -1331,6 +1338,7 @@ static void test_typelibmarshal(void)
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1350,6 +1358,7 @@ static void test_typelibmarshal(void)
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1481,6 +1490,7 @@ static void test_typelibmarshal(void)
hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEDISPATCH, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1498,6 +1508,7 @@ static void test_typelibmarshal(void)
hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONECOCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1514,6 +1525,7 @@ static void test_typelibmarshal(void)
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_COCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
todo_wine ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1533,6 +1545,7 @@ static void test_typelibmarshal(void)
hr = IDispatch_Invoke(pDispatch, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1588,9 +1601,9 @@ static void test_typelibmarshal(void)
V_I4(&vararg[1]) = 2;
hr = IWidget_VariantCArray(pWidget, 2, vararg);
ok_ole_success(hr, IWidget_VariantCArray);
- todo_wine
+ todo_wine_if(!tmarshal_todo)
ok(V_VT(&vararg[0]) == VT_I4 && V_I4(&vararg[0]) == 2, "vararg[0] = %d[%d]\n", V_VT(&vararg[0]), V_I4(&vararg[0]));
- todo_wine
+ todo_wine_if(!tmarshal_todo)
ok(V_VT(&vararg[1]) == VT_I4 && V_I4(&vararg[1]) == 3, "vararg[1] = %d[%d]\n", V_VT(&vararg[1]), V_I4(&vararg[1]));
/* call VarArg */
@@ -1661,6 +1674,7 @@ static void test_typelibmarshal(void)
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_ERROR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
ok(hr == DISP_E_EXCEPTION, "IDispatch_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1687,6 +1701,7 @@ static void test_typelibmarshal(void)
hr = ITypeInfo_Invoke(pTypeInfo, &NonOleAutomation, DISPID_NOA_ERROR, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
ok(hr == DISP_E_EXCEPTION, "ITypeInfo_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
ok(V_VT(&varresult) == VT_EMPTY, "V_VT(&varresult) should be VT_EMPTY instead of %d\n", V_VT(&varresult));
+ todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
@@ -1998,6 +2013,7 @@ static void test_external_connection(void)
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoUnmarshalInterface(stream, &IID_ItestDual, (void**)&iface);
+ todo_wine_if(tmarshal_todo)
ok(hres == S_OK, "CoUnmarshalInterface failed: %08x\n", hres);
ok(external_connections == 1, "external_connections = %d\n", external_connections);
@@ -2006,6 +2022,7 @@ static void test_external_connection(void)
/* Creating a stub for new iface causes new external connection. */
hres = ItestDual_QueryInterface(iface, &IID_ITestSecondDisp, (void**)&second);
+ todo_wine_if(tmarshal_todo)
ok(hres == S_OK, "Could not get ITestSecondDisp iface: %08x\n", hres);
todo_wine
ok(external_connections == 2, "external_connections = %d\n", external_connections);
@@ -2017,6 +2034,7 @@ static void test_external_connection(void)
expect_last_release_closes = TRUE;
ItestDual_Release(iface);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
end_host_object(tid, thread);
@@ -2028,12 +2046,14 @@ static void test_external_connection(void)
expect_last_release_closes = FALSE;
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
expect_last_release_closes = TRUE;
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
/* Two separated marshal data are still one external connection. */
@@ -2044,21 +2064,25 @@ static void test_external_connection(void)
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
hres = CoMarshalInterface(stream2, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
expect_last_release_closes = TRUE;
IStream_Seek(stream2, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream2);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Release(stream);
@@ -2070,17 +2094,20 @@ static void test_external_connection(void)
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLEWEAK);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoUnmarshalInterface(stream, &IID_ItestDual, (void**)&iface);
ok(hres == S_OK, "CoUnmarshalInterface failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
ItestDual_Release(iface);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
+ todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Release(stream);
--
2.16.1
2
1
14 Feb '18
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
Looking again at the mipmap generation checks, I think I don't need
the stuff I was adding in "wined3d: Refuse to create textures with
mipmap generation when unsupported." at all.
dlls/wined3d/directx.c | 8 ++------
dlls/wined3d/texture.c | 16 +++++++++++++---
dlls/wined3d/utils.c | 18 ++++++++++++++++++
dlls/wined3d/wined3d_private.h | 1 +
4 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index c8f42fe253a..924cc72e773 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -5296,7 +5296,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
const struct wined3d_format *adapter_format, *format;
enum wined3d_gl_resource_type gl_type, gl_type_end;
- BOOL mipmap_autogen_supported;
+ BOOL mipmap_autogen_supported = TRUE;
DWORD format_flags = 0;
DWORD allowed_usage;
@@ -5410,7 +5410,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
return WINED3DERR_NOTAVAILABLE;
}
- mipmap_autogen_supported = gl_info->supported[SGIS_GENERATE_MIPMAP];
for (; gl_type <= gl_type_end; ++gl_type)
{
if ((format->flags[gl_type] & format_flags) != format_flags)
@@ -5440,11 +5439,8 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
return WINED3DERR_NOTAVAILABLE;
}
- if ((format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
- != (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
- {
+ if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP))
mipmap_autogen_supported = FALSE;
- }
}
if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !mipmap_autogen_supported)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 750101fac66..740afeace80 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -386,8 +386,18 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
texture->flags |= WINED3D_TEXTURE_DISCARD;
if (flags & WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS)
{
- if (~format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
- & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
+ static const enum wined3d_gl_resource_type gl_type_from_res_type[] =
+ {
+ WINED3D_GL_RES_TYPE_BUFFER,
+ WINED3D_GL_RES_TYPE_BUFFER,
+ WINED3D_GL_RES_TYPE_TEX_2D,
+ WINED3D_GL_RES_TYPE_TEX_3D,
+ };
+ enum wined3d_gl_resource_type gl_type;
+
+ assert(desc->resource_type < ARRAY_SIZE(gl_type_from_res_type));
+ gl_type = gl_type_from_res_type[desc->resource_type];
+ if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP))
WARN("Format doesn't support mipmaps generation, "
"ignoring WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS flag.\n");
else
@@ -2685,7 +2695,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
}
- /* Generate all the surfaces. */
+ /* Generate all the sub resources. */
for (i = 0; i < texture->level_count; ++i)
{
struct wined3d_texture_sub_resource *sub_resource;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 6f7740deda0..960909f35b4 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3595,6 +3595,23 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
return TRUE;
}
+static void init_format_gen_mipmap_info(struct wined3d_gl_info *gl_info)
+{
+ unsigned int i, j;
+
+ if (!gl_info->supported[SGIS_GENERATE_MIPMAP] && !gl_info->fbo_ops.glGenerateMipmap)
+ return;
+
+ for (i = 0; i < gl_info->format_count; ++i)
+ {
+ struct wined3d_format *format = &gl_info->formats[i];
+
+ for (j = 0; j < ARRAY_SIZE(format->flags); ++j)
+ if (!(~format->flags[j] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)))
+ format->flags[j] |= WINED3DFMT_FLAG_GEN_MIPMAP;
+ }
+}
+
BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx)
{
static const struct wined3d_color red = {1.0f, 0.0f, 0.0f, 1.0f};
@@ -3783,6 +3800,7 @@ BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wi
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
+ init_format_gen_mipmap_info(gl_info);
init_format_depth_bias_scale(ctx, &adapter->d3d_info);
return TRUE;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f1f75301d6d..8201536a5de 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4205,6 +4205,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_TEXTURE 0x00080000
#define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
#define WINED3DFMT_FLAG_INTEGER 0x00200000
+#define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
struct wined3d_rational
{
--
2.13.6
4
13
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/dxgi/tests/device.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c
index 58c3bba64230..ee4a22b67d32 100644
--- a/dlls/dxgi/tests/device.c
+++ b/dlls/dxgi/tests/device.c
@@ -64,8 +64,6 @@ static HRESULT check_interface_(unsigned int line, void *iface, REFIID iid,
"Got hr %#x, expected %#x.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(out);
- else
- ok_(__FILE__, line)(!out, "Got unexpected pointer %p.\n", out);
return hr;
}
@@ -2562,7 +2560,7 @@ static void test_create_factory(void)
if (!pCreateDXGIFactory1)
{
- win_skip("CreateDXGIFactory1 not available, skipping tests.\n");
+ win_skip("CreateDXGIFactory1 not available.\n");
return;
}
@@ -2598,6 +2596,33 @@ static void test_create_factory(void)
refcount = IUnknown_Release(iface);
ok(!refcount, "Factory has %u references left.\n", refcount);
}
+
+ if (!pCreateDXGIFactory2)
+ {
+ win_skip("CreateDXGIFactory2 not available.\n");
+ return;
+ }
+
+ hr = pCreateDXGIFactory2(0, &IID_IDXGIFactory3, (void **)&iface);
+ ok(hr == S_OK, "Failed to create factory, hr %#x.\n", hr);
+ check_interface(iface, &IID_IDXGIFactory, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory1, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory2, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory3, TRUE, FALSE);
+ /* Not available on all Windows versions. */
+ check_interface(iface, &IID_IDXGIFactory4, TRUE, TRUE);
+ todo_wine check_interface(iface, &IID_IDXGIFactory5, TRUE, TRUE);
+ refcount = IUnknown_Release(iface);
+ ok(!refcount, "Factory has %u references left.\n", refcount);
+
+ hr = pCreateDXGIFactory2(0, &IID_IDXGIFactory, (void **)&iface);
+ ok(hr == S_OK, "Failed to create factory, hr %#x.\n", hr);
+ check_interface(iface, &IID_IDXGIFactory, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory1, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory2, TRUE, FALSE);
+ check_interface(iface, &IID_IDXGIFactory3, TRUE, FALSE);
+ refcount = IUnknown_Release(iface);
+ ok(!refcount, "Factory has %u references left.\n", refcount);
}
static void test_private_data(void)
--
2.13.6
2
13
2
1
14 Feb '18
Signed-off-by: Kirill Erofeev <erofeev.info(a)gmail.com>
---
dlls/msvcrt/tests/dir.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c
index aa273ea..0750b34 100644
--- a/dlls/msvcrt/tests/dir.c
+++ b/dlls/msvcrt/tests/dir.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
+#include <direct.h>
#include <sys/stat.h>
#include <io.h>
#include <mbctype.h>
@@ -416,6 +417,112 @@ static void test_splitpath(void)
_setmbcp(prev_cp);
}
+static void test_search_environment(void)
+{
+ const char* dirs[] = {
+ "c:\\search_env_test",
+ "c:\\search_env_test\\dir1",
+ "c:\\search_env_test\\dir2",
+ "c:\\search_env_test\\dir3longer",
+ NULL };
+
+ const char* files[] = {
+ "c:\\search_env_test\\dir1\\1.dat",
+ "c:\\search_env_test\\dir1\\2.dat",
+ "c:\\search_env_test\\dir2\\1.dat",
+ "c:\\search_env_test\\dir2\\3.dat",
+ "c:\\search_env_test\\dir3longer\\3.dat",
+ NULL };
+
+ FILE* tmp_file = NULL;
+ const char** file_name = files;
+ const char** dir_name = dirs;
+ char result[MAX_PATH];
+
+ const char eraser[] = "TEST_PATH=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+ while (*dir_name){
+ ok(!mkdir(*dir_name), "Failed to setup test environment (dir = %s)\n", *dir_name);
+ dir_name++;
+ }
+
+ while (*file_name){
+ tmp_file = fopen(*file_name, "wb");
+ ok(tmp_file != NULL, "Failed to setup test environment (file = %s)\n", *file_name);
+ if (tmp_file)
+ fclose(tmp_file);
+ file_name++;
+ }
+
+
+ /*To catch some errors (usage of uninitialized memory) we will trick searchenv to set up memory to predefined values*/
+ putenv(eraser);
+ _searchenv("1.dat", "TEST_PATH", result);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv("1.dat", "TEST_PATH", result);
+ ok(!strcmp(result, "c:\\search_env_test\\dir1\\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\\search_env_test\\dir1", result);
+
+ putenv(eraser);
+ _searchenv("1.dat", "TEST_PATH", result);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv("3.dat", "TEST_PATH", result);
+ ok(!strcmp(result, "c:\\search_env_test\\dir2\\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\\search_env_test\\dir2", result);
+
+ putenv(eraser);
+ _searchenv("1.dat", "TEST_PATH", result);
+ putenv("TEST_PATH=;c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv("1.dat", "TEST_PATH", result);
+ ok(!strcmp(result, "c:\\search_env_test\\dir1\\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\\search_env_test\\dir1", result);
+
+ putenv(eraser);
+ _searchenv("1.dat", "TEST_PATH", result);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv("3.dat", "TEST_PATH", result);
+ ok(!strcmp(result, "c:\\search_env_test\\dir2\\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\\search_env_test\\dir2", result);
+
+
+
+
+
+ putenv(eraser);
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ ok(!strcmp(result, "c:\\search_env_test\\dir1\\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\\search_env_test\\dir1", result);
+
+ putenv(eraser);
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv_s("3.dat", "TEST_PATH", result, MAX_PATH);
+ ok(!strcmp(result, "c:\\search_env_test\\dir2\\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\\search_env_test\\dir2", result);
+
+ putenv(eraser);
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ putenv("TEST_PATH=;c:\\search_env_test\\dir1;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ ok(!strcmp(result, "c:\\search_env_test\\dir1\\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\\search_env_test\\dir1", result);
+
+ putenv(eraser);
+ _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH);
+ putenv("TEST_PATH=c:\\search_env_test\\dir1;;c:\\search_env_test\\dir2;c:\\search_env_test\\dir3longer");
+ _searchenv_s("3.dat", "TEST_PATH", result, MAX_PATH);
+ ok(!strcmp(result, "c:\\search_env_test\\dir2\\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\\search_env_test\\dir2", result);
+
+
+
+
+ putenv("TEST_PATH=");
+
+ do {
+ file_name--;
+ ok(!remove(*file_name), "Failed cleanup test (file = %s)\n", *file_name);
+ }while(files != file_name);
+
+ do {
+ dir_name--;
+ ok(!rmdir(*dir_name), "Failed cleanup test (dir = %s)\n", *dir_name);
+ }while(dirs != dir_name);
+}
+
START_TEST(dir)
{
init();
@@ -424,4 +531,6 @@ START_TEST(dir)
test_makepath();
test_makepath_s();
test_splitpath();
+
+ test_search_environment();
}
--
2.7.4
2
5
[PATCH 3/3] gdi32: Fix text metrics in synthetic bold bitmap fonts. (rebased)
by Akihiro Sagawa 14 Feb '18
by Akihiro Sagawa 14 Feb '18
14 Feb '18
Fixes Bug 44473.
Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com>
---
dlls/gdi32/freetype.c | 9 +++++++--
dlls/gdi32/tests/font.c | 3 ---
2 files changed, 7 insertions(+), 5 deletions(-)
2
4
1
0
14 Feb '18
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/dispatcher.c | 15 +-
dlls/secur32/lsa.c | 50 ++---
dlls/secur32/negotiate.c | 48 ++---
dlls/secur32/ntlm.c | 460 +++++++++++++++++------------------------
dlls/secur32/schannel.c | 55 +++--
dlls/secur32/schannel_macosx.c | 6 +-
dlls/secur32/secur32.c | 43 ++--
dlls/secur32/secur32_priv.h | 1 +
dlls/secur32/thunks.c | 16 +-
dlls/secur32/util.c | 12 +-
dlls/secur32/wrapper.c | 10 +-
11 files changed, 311 insertions(+), 405 deletions(-)
diff --git a/dlls/secur32/dispatcher.c b/dlls/secur32/dispatcher.c
index 5a9e26ae19..0871576848 100644
--- a/dlls/secur32/dispatcher.c
+++ b/dlls/secur32/dispatcher.c
@@ -81,7 +81,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
fcntl( pipe_out[1], F_SETFD, FD_CLOEXEC );
}
- if (!(helper = HeapAlloc(GetProcessHeap(),0, sizeof(NegoHelper))))
+ if (!(helper = heap_alloc( sizeof(NegoHelper) )))
{
close(pipe_in[0]);
close(pipe_in[1]);
@@ -98,7 +98,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
close(pipe_in[1]);
close(pipe_out[0]);
close(pipe_out[1]);
- HeapFree( GetProcessHeap(), 0, helper );
+ heap_free( helper );
return SEC_E_INTERNAL_ERROR;
}
@@ -156,7 +156,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len)
if(helper->com_buf == NULL)
{
TRACE("Creating a new buffer for the helper\n");
- if((helper->com_buf = HeapAlloc(GetProcessHeap(), 0, INITIAL_BUFFER_SIZE)) == NULL)
+ if (!(helper->com_buf = heap_alloc(INITIAL_BUFFER_SIZE)))
return SEC_E_INSUFFICIENT_MEMORY;
/* Created a new buffer, size is INITIAL_BUFFER_SIZE, offset is 0 */
@@ -170,8 +170,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len)
if(helper->com_buf_offset + INITIAL_BUFFER_SIZE > helper->com_buf_size)
{
/* increment buffer size in INITIAL_BUFFER_SIZE steps */
- char *buf = HeapReAlloc(GetProcessHeap(), 0, helper->com_buf,
- helper->com_buf_size + INITIAL_BUFFER_SIZE);
+ char *buf = heap_realloc(helper->com_buf, helper->com_buf_size + INITIAL_BUFFER_SIZE);
TRACE("Resizing buffer!\n");
if (!buf) return SEC_E_INSUFFICIENT_MEMORY;
helper->com_buf_size += INITIAL_BUFFER_SIZE;
@@ -280,8 +279,8 @@ void cleanup_helper(PNegoHelper helper)
if(helper == NULL)
return;
- HeapFree(GetProcessHeap(), 0, helper->com_buf);
- HeapFree(GetProcessHeap(), 0, helper->session_key);
+ heap_free(helper->com_buf);
+ heap_free(helper->session_key);
/* closing stdin will terminate ntlm_auth */
close(helper->pipe_out);
@@ -297,7 +296,7 @@ void cleanup_helper(PNegoHelper helper)
}
#endif
- HeapFree(GetProcessHeap(), 0, helper);
+ heap_free(helper);
}
void check_version(PNegoHelper helper)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index b93006a24f..23b380cd58 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -94,7 +94,7 @@ NTSTATUS WINAPI LsaConnectUntrusted(PHANDLE LsaHandle)
TRACE("%p\n", LsaHandle);
- lsa_conn = HeapAlloc(GetProcessHeap(), 0, sizeof(*lsa_conn));
+ lsa_conn = heap_alloc(sizeof(*lsa_conn));
if (!lsa_conn) return STATUS_NO_MEMORY;
lsa_conn->magic = LSA_MAGIC;
@@ -122,7 +122,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount,
NTSTATUS WINAPI LsaFreeReturnBuffer(PVOID buffer)
{
TRACE("%p\n", buffer);
- HeapFree(GetProcessHeap(), 0, buffer);
+ heap_free(buffer);
return STATUS_SUCCESS;
}
@@ -186,26 +186,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA
static void * NTAPI lsa_AllocateLsaHeap(ULONG size)
{
TRACE("%u\n", size);
- return HeapAlloc(GetProcessHeap(), 0, size);
+ return heap_alloc(size);
}
static void NTAPI lsa_FreeLsaHeap(void *p)
{
TRACE("%p\n", p);
- HeapFree(GetProcessHeap(), 0, p);
+ heap_free(p);
}
static NTSTATUS NTAPI lsa_AllocateClientBuffer(PLSA_CLIENT_REQUEST req, ULONG size, void **p)
{
TRACE("%p,%u,%p\n", req, size, p);
- *p = HeapAlloc(GetProcessHeap(), 0, size);
+ *p = heap_alloc(size);
return *p ? STATUS_SUCCESS : STATUS_NO_MEMORY;
}
static NTSTATUS NTAPI lsa_FreeClientBuffer(PLSA_CLIENT_REQUEST req, void *p)
{
TRACE("%p,%p\n", req, p);
- HeapFree(GetProcessHeap(), 0, p);
+ heap_free(p);
return STATUS_SUCCESS;
}
@@ -328,13 +328,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (principal)
{
int len = MultiByteToWideChar( CP_ACP, 0, principal, -1, NULL, 0 );
- if (!(principalW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(principalW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, principal, -1, principalW, len );
}
if (package)
{
int len = MultiByteToWideChar( CP_ACP, 0, package, -1, NULL, 0 );
- if (!(packageW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(packageW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, package, -1, packageW, len );
}
if (auth_data)
@@ -343,23 +343,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- if (!(auth_dataW = HeapAlloc( GetProcessHeap(), 0, sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
+ if (!(auth_dataW = heap_alloc( sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
if (id->UserLength)
{
len_user = MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, NULL, 0 );
- if (!(user = HeapAlloc( GetProcessHeap(), 0, len_user * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(user = heap_alloc( len_user * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, user, len_user );
}
if (id->DomainLength)
{
len_domain = MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, NULL, 0 );
- if (!(domain = HeapAlloc( GetProcessHeap(), 0, len_domain * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(domain = heap_alloc( len_domain * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, domain, len_domain );
}
if (id->PasswordLength)
{
len_passwd = MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, NULL, 0 );
- if (!(passwd = HeapAlloc( GetProcessHeap(), 0, len_passwd * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(passwd = heap_alloc( len_passwd * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, passwd, len_passwd );
}
auth_dataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
@@ -376,12 +376,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
status = lsa_AcquireCredentialsHandleW( principalW, packageW, credentials_use, logon_id, auth_dataW, get_key_fn,
get_key_arg, credential, ts_expiry );
done:
- if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) HeapFree( GetProcessHeap(), 0, auth_dataW );
- HeapFree( GetProcessHeap(), 0, packageW );
- HeapFree( GetProcessHeap(), 0, principalW );
- HeapFree( GetProcessHeap(), 0, user );
- HeapFree( GetProcessHeap(), 0, domain );
- HeapFree( GetProcessHeap(), 0, passwd );
+ if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) heap_free( auth_dataW );
+ heap_free( packageW );
+ heap_free( principalW );
+ heap_free( user );
+ heap_free( domain );
+ heap_free( passwd );
return status;
}
@@ -464,13 +464,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
if (target_name)
{
int len = MultiByteToWideChar( CP_ACP, 0, target_name, -1, NULL, 0 );
- if (!(targetW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(targetW = heap_alloc( len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, target_name, -1, targetW, len );
}
status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep,
input, reserved2, new_context, output, context_attr, ts_expiry );
- HeapFree( GetProcessHeap(), 0, targetW );
+ heap_free( targetW );
return status;
}
@@ -560,7 +560,7 @@ static SecPkgInfoA *package_infoWtoA( const SecPkgInfoW *info )
int size_name = WideCharToMultiByte( CP_ACP, 0, info->Name, -1, NULL, 0, NULL, NULL );
int size_comment = WideCharToMultiByte( CP_ACP, 0, info->Comment, -1, NULL, 0, NULL, NULL );
- if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
+ if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@@ -778,9 +778,9 @@ static void add_package(struct lsa_package *package)
struct lsa_package *new_loaded_packages;
if (!loaded_packages)
- new_loaded_packages = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_loaded_packages));
+ new_loaded_packages = heap_alloc(sizeof(*new_loaded_packages));
else
- new_loaded_packages = HeapReAlloc(GetProcessHeap(), 0, loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
+ new_loaded_packages = heap_realloc(loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
if (new_loaded_packages)
{
@@ -884,7 +884,7 @@ void load_auth_packages(void)
{
SecPkgInfoW *info;
- info = HeapAlloc(GetProcessHeap(), 0, loaded_packages[i].lsa_table_count * sizeof(*info));
+ info = heap_alloc(loaded_packages[i].lsa_table_count * sizeof(*info));
if (info)
{
NTSTATUS status;
@@ -893,7 +893,7 @@ void load_auth_packages(void)
if (status == STATUS_SUCCESS)
SECUR32_addPackages(provider, loaded_packages[i].lsa_table_count, NULL, info);
- HeapFree(GetProcessHeap(), 0, info);
+ heap_free(info);
}
}
}
diff --git a/dlls/secur32/negotiate.c b/dlls/secur32/negotiate.c
index 5000f0f953..0df950093e 100644
--- a/dlls/secur32/negotiate.c
+++ b/dlls/secur32/negotiate.c
@@ -77,7 +77,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
if (!pszPackage) return SEC_E_SECPKG_NOT_FOUND;
- if (!(cred = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(cred = heap_alloc_zero( sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
if ((package = SECUR32_findPackageW( kerberosW )))
{
@@ -105,7 +105,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
return SEC_E_OK;
}
- HeapFree( GetProcessHeap(), 0, cred );
+ heap_free( cred );
return ret;
}
@@ -128,8 +128,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (pszPackage)
{
int package_len = MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, NULL, 0 );
- package = HeapAlloc( GetProcessHeap(), 0, package_len * sizeof(SEC_WCHAR) );
- if (!package) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(package = heap_alloc( package_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, package, package_len );
}
if (pAuthData)
@@ -139,16 +138,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- identityW = HeapAlloc( GetProcessHeap(), 0, sizeof(*identityW) );
- if (!identityW) goto done;
+ if (!(identityW = heap_alloc( sizeof(*identityW) ))) goto done;
if (!identity->UserLength) user_len = 0;
else
{
user_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User,
identity->UserLength, NULL, 0 );
- user = HeapAlloc( GetProcessHeap(), 0, user_len * sizeof(SEC_WCHAR) );
- if (!user) goto done;
+ if (!(user = heap_alloc( user_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, identity->UserLength,
user, user_len );
}
@@ -157,8 +154,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
domain_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain,
identity->DomainLength, NULL, 0 );
- domain = HeapAlloc( GetProcessHeap(), 0, domain_len * sizeof(SEC_WCHAR) );
- if (!domain) goto done;
+ if (!(domain = heap_alloc( domain_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, identity->DomainLength,
domain, domain_len );
}
@@ -167,8 +163,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
passwd_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password,
identity->PasswordLength, NULL, 0 );
- passwd = HeapAlloc( GetProcessHeap(), 0, passwd_len * sizeof(SEC_WCHAR) );
- if (!passwd) goto done;
+ if (!(passwd = heap_alloc( passwd_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, identity->PasswordLength,
passwd, passwd_len );
}
@@ -185,11 +180,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
ret = nego_AcquireCredentialsHandleW( NULL, package, fCredentialUse, pLogonID, identityW,
pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry );
done:
- HeapFree( GetProcessHeap(), 0, package );
- HeapFree( GetProcessHeap(), 0, user );
- HeapFree( GetProcessHeap(), 0, domain );
- HeapFree( GetProcessHeap(), 0, passwd );
- HeapFree( GetProcessHeap(), 0, identityW );
+ heap_free( package );
+ heap_free( user );
+ heap_free( domain );
+ heap_free( passwd );
+ heap_free( identityW );
return ret;
}
@@ -217,8 +212,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
- if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
- return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@@ -252,7 +246,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
}
}
- HeapFree( GetProcessHeap(), 0, new_ctxt );
+ heap_free( new_ctxt );
return ret;
}
@@ -276,14 +270,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
if (pszTargetName)
{
int target_len = MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, NULL, 0 );
- target = HeapAlloc(GetProcessHeap(), 0, target_len * sizeof(SEC_WCHAR) );
- if (!target) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(target = heap_alloc( target_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, target, target_len );
}
ret = nego_InitializeSecurityContextW( phCredential, phContext, target, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry );
- HeapFree( GetProcessHeap(), 0, target );
+ heap_free( target );
return ret;
}
@@ -309,8 +302,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
- if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
- return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@@ -344,7 +336,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
}
}
- HeapFree( GetProcessHeap(), 0, new_ctxt );
+ heap_free( new_ctxt );
return ret;
}
@@ -384,7 +376,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm );
}
TRACE( "freeing %p\n", ctxt );
- HeapFree( GetProcessHeap(), 0, ctxt );
+ heap_free( ctxt );
return ret;
}
@@ -543,7 +535,7 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden
if (cred->krb) cred->krb->fnTableW.FreeCredentialsHandle( &cred->handle_krb );
if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm );
- HeapFree( GetProcessHeap(), 0, cred );
+ heap_free( cred );
return SEC_E_OK;
}
diff --git a/dlls/secur32/ntlm.c b/dlls/secur32/ntlm.c
index 6a94d4224c..49845c33f9 100644
--- a/dlls/secur32/ntlm.c
+++ b/dlls/secur32/ntlm.c
@@ -93,8 +93,7 @@ static char *ntlm_GetUsernameArg(LPCWSTR userW, INT userW_length)
unixcp_size = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
userW, userW_length, NULL, 0, NULL, NULL) + sizeof(username_arg);
- user = HeapAlloc(GetProcessHeap(), 0, unixcp_size);
- if (!user) return NULL;
+ if (!(user = heap_alloc(unixcp_size))) return NULL;
memcpy(user, username_arg, sizeof(username_arg) - 1);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, userW, userW_length,
user + sizeof(username_arg) - 1,
@@ -111,8 +110,7 @@ static char *ntlm_GetDomainArg(LPCWSTR domainW, INT domainW_length)
unixcp_size = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
domainW, domainW_length, NULL, 0, NULL, NULL) + sizeof(domain_arg);
- domain = HeapAlloc(GetProcessHeap(), 0, unixcp_size);
- if (!domain) return NULL;
+ if (!(domain = heap_alloc(unixcp_size))) return NULL;
memcpy(domain, domain_arg, sizeof(domain_arg) - 1);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, domainW,
domainW_length, domain + sizeof(domain_arg) - 1,
@@ -129,8 +127,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
- SECURITY_STATUS ret;
- PNtlmCredentials ntlm_cred;
+ SECURITY_STATUS ret = SEC_E_INSUFFICIENT_MEMORY;
+ PNtlmCredentials ntlm_cred = NULL;
LPWSTR domain = NULL, user = NULL, password = NULL;
PSEC_WINNT_AUTH_IDENTITY_W auth_data = NULL;
@@ -138,149 +136,117 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
- switch(fCredentialUse)
+ switch (fCredentialUse)
{
- case SECPKG_CRED_INBOUND:
- ntlm_cred = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntlm_cred));
- if (!ntlm_cred)
- ret = SEC_E_INSUFFICIENT_MEMORY;
- else
- {
- ntlm_cred->mode = NTLM_SERVER;
- ntlm_cred->username_arg = NULL;
- ntlm_cred->domain_arg = NULL;
- ntlm_cred->password = NULL;
- ntlm_cred->pwlen = 0;
- ntlm_cred->no_cached_credentials = 0;
-
- phCredential->dwUpper = fCredentialUse;
- phCredential->dwLower = (ULONG_PTR)ntlm_cred;
- ret = SEC_E_OK;
- }
- break;
- case SECPKG_CRED_OUTBOUND:
+ case SECPKG_CRED_INBOUND:
+ if (!(ntlm_cred = heap_alloc(sizeof(*ntlm_cred)))) return SEC_E_INSUFFICIENT_MEMORY;
+ ntlm_cred->mode = NTLM_SERVER;
+ ntlm_cred->username_arg = NULL;
+ ntlm_cred->domain_arg = NULL;
+ ntlm_cred->password = NULL;
+ ntlm_cred->pwlen = 0;
+ ntlm_cred->no_cached_credentials = 0;
+
+ phCredential->dwUpper = fCredentialUse;
+ phCredential->dwLower = (ULONG_PTR)ntlm_cred;
+ ret = SEC_E_OK;
+ break;
+
+ case SECPKG_CRED_OUTBOUND:
+ auth_data = pAuthData;
+ if (!(ntlm_cred = heap_alloc(sizeof(*ntlm_cred)))) return SEC_E_INSUFFICIENT_MEMORY;
+
+ ntlm_cred->mode = NTLM_CLIENT;
+ ntlm_cred->username_arg = NULL;
+ ntlm_cred->domain_arg = NULL;
+ ntlm_cred->password = NULL;
+ ntlm_cred->pwlen = 0;
+ ntlm_cred->no_cached_credentials = 0;
+
+ if (pAuthData)
+ {
+ int domain_len = 0, user_len = 0, password_len = 0;
+
+ if (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- auth_data = pAuthData;
- ntlm_cred = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntlm_cred));
- if (!ntlm_cred)
+ if (auth_data->DomainLength)
{
- ret = SEC_E_INSUFFICIENT_MEMORY;
- break;
+ domain_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain,
+ auth_data->DomainLength, NULL, 0);
+ if (!(domain = heap_alloc(sizeof(WCHAR) * domain_len))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain, auth_data->DomainLength,
+ domain, domain_len);
+ }
+ if (auth_data->UserLength)
+ {
+ user_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User,
+ auth_data->UserLength, NULL, 0);
+ if (!(user = heap_alloc(sizeof(WCHAR) * user_len))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User, auth_data->UserLength,
+ user, user_len);
}
- ntlm_cred->mode = NTLM_CLIENT;
- ntlm_cred->username_arg = NULL;
- ntlm_cred->domain_arg = NULL;
- ntlm_cred->password = NULL;
- ntlm_cred->pwlen = 0;
- ntlm_cred->no_cached_credentials = 0;
-
- if(pAuthData != NULL)
+ if (auth_data->PasswordLength)
{
- int domain_len = 0, user_len = 0, password_len = 0;
-
- if (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
- {
- if (auth_data->DomainLength)
- {
- domain_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain,
- auth_data->DomainLength, NULL, 0);
- domain = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * domain_len);
- if(!domain)
- {
- ret = SEC_E_INSUFFICIENT_MEMORY;
- break;
- }
- MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain, auth_data->DomainLength,
- domain, domain_len);
- }
-
- if (auth_data->UserLength)
- {
- user_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User,
- auth_data->UserLength, NULL, 0);
- user = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * user_len);
- if(!user)
- {
- ret = SEC_E_INSUFFICIENT_MEMORY;
- break;
- }
- MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User, auth_data->UserLength,
- user, user_len);
- }
-
- if (auth_data->PasswordLength)
- {
- password_len = MultiByteToWideChar(CP_ACP, 0,(char *)auth_data->Password,
- auth_data->PasswordLength, NULL, 0);
- password = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * password_len);
- if(!password)
- {
- ret = SEC_E_INSUFFICIENT_MEMORY;
- break;
- }
- MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Password, auth_data->PasswordLength,
- password, password_len);
- }
- }
- else
- {
- domain = auth_data->Domain;
- domain_len = auth_data->DomainLength;
-
- user = auth_data->User;
- user_len = auth_data->UserLength;
-
- password = auth_data->Password;
- password_len = auth_data->PasswordLength;
- }
-
- TRACE("Username is %s\n", debugstr_wn(user, user_len));
- TRACE("Domain name is %s\n", debugstr_wn(domain, domain_len));
-
- ntlm_cred->username_arg = ntlm_GetUsernameArg(user, user_len);
- ntlm_cred->domain_arg = ntlm_GetDomainArg(domain, domain_len);
-
- if(password_len != 0)
- {
- ntlm_cred->pwlen = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password,
- password_len, NULL, 0, NULL, NULL);
-
- ntlm_cred->password = HeapAlloc(GetProcessHeap(), 0,
- ntlm_cred->pwlen);
- if(!ntlm_cred->password)
- {
- ret = SEC_E_INSUFFICIENT_MEMORY;
- break;
- }
-
- WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password, password_len,
- ntlm_cred->password, ntlm_cred->pwlen, NULL, NULL);
- }
+ password_len = MultiByteToWideChar(CP_ACP, 0,(char *)auth_data->Password,
+ auth_data->PasswordLength, NULL, 0);
+ if (!(password = heap_alloc(sizeof(WCHAR) * password_len))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Password, auth_data->PasswordLength,
+ password, password_len);
}
+ }
+ else
+ {
+ domain = auth_data->Domain;
+ domain_len = auth_data->DomainLength;
+
+ user = auth_data->User;
+ user_len = auth_data->UserLength;
- phCredential->dwUpper = fCredentialUse;
- phCredential->dwLower = (ULONG_PTR)ntlm_cred;
- TRACE("ACH phCredential->dwUpper: 0x%08lx, dwLower: 0x%08lx\n",
- phCredential->dwUpper, phCredential->dwLower);
- ret = SEC_E_OK;
- break;
+ password = auth_data->Password;
+ password_len = auth_data->PasswordLength;
}
- case SECPKG_CRED_BOTH:
- FIXME("AcquireCredentialsHandle: SECPKG_CRED_BOTH stub\n");
- ret = SEC_E_UNSUPPORTED_FUNCTION;
- phCredential = NULL;
- break;
- default:
- phCredential = NULL;
- ret = SEC_E_UNKNOWN_CREDENTIALS;
+
+ TRACE("Username is %s\n", debugstr_wn(user, user_len));
+ TRACE("Domain name is %s\n", debugstr_wn(domain, domain_len));
+
+ ntlm_cred->username_arg = ntlm_GetUsernameArg(user, user_len);
+ ntlm_cred->domain_arg = ntlm_GetDomainArg(domain, domain_len);
+
+ if (password_len)
+ {
+ ntlm_cred->pwlen = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password,
+ password_len, NULL, 0, NULL, NULL);
+ if (!(ntlm_cred->password = heap_alloc(ntlm_cred->pwlen))) goto done;
+ WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password, password_len,
+ ntlm_cred->password, ntlm_cred->pwlen, NULL, NULL);
+ }
+ }
+
+ phCredential->dwUpper = fCredentialUse;
+ phCredential->dwLower = (ULONG_PTR)ntlm_cred;
+ TRACE("ACH phCredential->dwUpper: 0x%08lx, dwLower: 0x%08lx\n", phCredential->dwUpper,
+ phCredential->dwLower);
+ ret = SEC_E_OK;
+ break;
+
+ case SECPKG_CRED_BOTH:
+ FIXME("AcquireCredentialsHandle: SECPKG_CRED_BOTH stub\n");
+ ret = SEC_E_UNSUPPORTED_FUNCTION;
+ break;
+
+ default:
+ ret = SEC_E_UNKNOWN_CREDENTIALS;
}
- if (auth_data && auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
+done:
+ if (auth_data && (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI))
{
- HeapFree(GetProcessHeap(), 0, domain);
- HeapFree(GetProcessHeap(), 0, user);
- HeapFree(GetProcessHeap(), 0, password);
+ heap_free(domain);
+ heap_free(user);
+ heap_free(password);
}
+ if (ret != SEC_E_OK) heap_free( ntlm_cred );
+
return ret;
}
@@ -292,81 +258,54 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
- SECURITY_STATUS ret;
+ SECURITY_STATUS ret = SEC_E_INSUFFICIENT_MEMORY;
int user_sizeW, domain_sizeW, passwd_sizeW;
-
SEC_WCHAR *user = NULL, *domain = NULL, *passwd = NULL, *package = NULL;
-
PSEC_WINNT_AUTH_IDENTITY_W pAuthDataW = NULL;
- PSEC_WINNT_AUTH_IDENTITY_A identity = NULL;
+ PSEC_WINNT_AUTH_IDENTITY_A id = NULL;
TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p)\n",
debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse,
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
-
- if(pszPackage != NULL)
- {
- int package_sizeW = MultiByteToWideChar(CP_ACP, 0, pszPackage, -1,
- NULL, 0);
- package = HeapAlloc(GetProcessHeap(), 0, package_sizeW *
- sizeof(SEC_WCHAR));
+ if (pszPackage)
+ {
+ int package_sizeW = MultiByteToWideChar(CP_ACP, 0, pszPackage, -1, NULL, 0);
+ if (!(package = heap_alloc(package_sizeW * sizeof(SEC_WCHAR)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszPackage, -1, package, package_sizeW);
}
-
- if(pAuthData != NULL)
+ if (pAuthData)
{
- identity = pAuthData;
-
- if(identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
+ id = pAuthData;
+ if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- pAuthDataW = HeapAlloc(GetProcessHeap(), 0,
- sizeof(SEC_WINNT_AUTH_IDENTITY_W));
+ if (!(pAuthDataW = heap_alloc(sizeof(SEC_WINNT_AUTH_IDENTITY_W)))) goto done;
- if(identity->UserLength != 0)
- {
- user_sizeW = MultiByteToWideChar(CP_ACP, 0,
- (LPCSTR)identity->User, identity->UserLength, NULL, 0);
- user = HeapAlloc(GetProcessHeap(), 0, user_sizeW *
- sizeof(SEC_WCHAR));
- MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->User,
- identity->UserLength, user, user_sizeW);
- }
+ if (!id->UserLength) user_sizeW = 0;
else
{
- user_sizeW = 0;
- }
-
- if(identity->DomainLength != 0)
- {
- domain_sizeW = MultiByteToWideChar(CP_ACP, 0,
- (LPCSTR)identity->Domain, identity->DomainLength, NULL, 0);
- domain = HeapAlloc(GetProcessHeap(), 0, domain_sizeW
- * sizeof(SEC_WCHAR));
- MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->Domain,
- identity->DomainLength, domain, domain_sizeW);
+ user_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->User, id->UserLength, NULL, 0);
+ if (!(user = heap_alloc(user_sizeW * sizeof(SEC_WCHAR)))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->User, id->UserLength, user, user_sizeW);
}
+
+ if (!id->DomainLength) domain_sizeW = 0;
else
{
- domain_sizeW = 0;
+ domain_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Domain, id->DomainLength, NULL, 0);
+ if (!(domain = heap_alloc(domain_sizeW * sizeof(SEC_WCHAR)))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Domain, id->DomainLength, domain, domain_sizeW);
}
- if(identity->PasswordLength != 0)
- {
- passwd_sizeW = MultiByteToWideChar(CP_ACP, 0,
- (LPCSTR)identity->Password, identity->PasswordLength,
- NULL, 0);
- passwd = HeapAlloc(GetProcessHeap(), 0, passwd_sizeW
- * sizeof(SEC_WCHAR));
- MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->Password,
- identity->PasswordLength, passwd, passwd_sizeW);
- }
+ if (!id->PasswordLength) passwd_sizeW = 0;
else
{
- passwd_sizeW = 0;
+ passwd_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Password, id->PasswordLength, NULL, 0);
+ if (!(passwd = heap_alloc(passwd_sizeW * sizeof(SEC_WCHAR)))) goto done;
+ MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Password, id->PasswordLength, passwd, passwd_sizeW);
}
-
+
pAuthDataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
pAuthDataW->User = user;
pAuthDataW->UserLength = user_sizeW;
@@ -375,23 +314,20 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
pAuthDataW->Password = passwd;
pAuthDataW->PasswordLength = passwd_sizeW;
}
- else
- {
- pAuthDataW = (PSEC_WINNT_AUTH_IDENTITY_W)identity;
- }
- }
-
+ else pAuthDataW = (PSEC_WINNT_AUTH_IDENTITY_W)id;
+ }
+
ret = ntlm_AcquireCredentialsHandleW(NULL, package, fCredentialUse,
pLogonID, pAuthDataW, pGetKeyFn, pGetKeyArgument, phCredential,
ptsExpiry);
-
- HeapFree(GetProcessHeap(), 0, package);
- HeapFree(GetProcessHeap(), 0, user);
- HeapFree(GetProcessHeap(), 0, domain);
- HeapFree(GetProcessHeap(), 0, passwd);
- if(pAuthDataW != (PSEC_WINNT_AUTH_IDENTITY_W)identity)
- HeapFree(GetProcessHeap(), 0, pAuthDataW);
-
+
+done:
+ heap_free(package);
+ heap_free(user);
+ heap_free(domain);
+ heap_free(passwd);
+ if (pAuthDataW != (PSEC_WINNT_AUTH_IDENTITY_W)id) heap_free(pAuthDataW);
+
return ret;
}
@@ -465,16 +401,13 @@ static BOOL ntlm_GetCachedCredential(const SEC_WCHAR *pszTargetName, PCREDENTIAL
p = pszHost + strlenW(pszHost);
}
- pszHostOnly = HeapAlloc(GetProcessHeap(), 0, (p - pszHost + 1) * sizeof(WCHAR));
- if (!pszHostOnly)
- return FALSE;
-
+ if (!(pszHostOnly = heap_alloc((p - pszHost + 1) * sizeof(WCHAR)))) return FALSE;
memcpy(pszHostOnly, pszHost, (p - pszHost) * sizeof(WCHAR));
pszHostOnly[p - pszHost] = '\0';
ret = CredReadW(pszHostOnly, CRED_TYPE_DOMAIN_PASSWORD, 0, cred);
- HeapFree(GetProcessHeap(), 0, pszHostOnly);
+ heap_free(pszHostOnly);
return ret;
}
@@ -521,8 +454,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
TRACE("Setting SECURITY_NETWORK_DREP\n");
}
- buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(char) * NTLM_MAX_BUF);
- bin = HeapAlloc(GetProcessHeap(), 0, sizeof(BYTE) * NTLM_MAX_BUF);
+ buffer = heap_alloc(sizeof(char) * NTLM_MAX_BUF);
+ bin = heap_alloc(sizeof(BYTE) * NTLM_MAX_BUF);
if((phContext == NULL) && (pInput == NULL))
{
@@ -582,8 +515,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
cred->CredentialBlobSize / sizeof(WCHAR), NULL, 0,
NULL, NULL);
- password = HeapAlloc(GetProcessHeap(), 0, pwlen);
-
+ password = heap_alloc(pwlen);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
(LPWSTR)cred->CredentialBlob,
cred->CredentialBlobSize / sizeof(WCHAR),
@@ -625,7 +557,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
goto isc_end;
helper->mode = NTLM_CLIENT;
- helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
+ helper->session_key = heap_alloc(16);
if (!helper->session_key)
{
cleanup_helper(helper);
@@ -644,15 +576,13 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
password ? password : ntlm_cred->password,
password ? pwlen : ntlm_cred->pwlen,
NULL, 0);
- unicode_password = HeapAlloc(GetProcessHeap(), 0,
- passwd_lenW * sizeof(SEC_WCHAR));
+ unicode_password = heap_alloc(passwd_lenW * sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, password ? password : ntlm_cred->password,
password ? pwlen : ntlm_cred->pwlen, unicode_password, passwd_lenW);
SECUR32_CreateNTLM1SessionKey((PBYTE)unicode_password,
passwd_lenW * sizeof(SEC_WCHAR), helper->session_key);
-
- HeapFree(GetProcessHeap(), 0, unicode_password);
+ heap_free(unicode_password);
}
else
memset(helper->session_key, 0, 16);
@@ -661,8 +591,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
* "SF NTLMSSP_FEATURE_SIGN NTLMSSP_FEATURE_SEAL
* NTLMSSP_FEATURE_SESSION_KEY"
*/
- want_flags = HeapAlloc(GetProcessHeap(), 0, 73);
- if(want_flags == NULL)
+ if (!(want_flags = heap_alloc(73)))
{
cleanup_helper(helper);
ret = SEC_E_INSUFFICIENT_MEMORY;
@@ -889,7 +818,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
if (fContextReq & ISC_REQ_ALLOCATE_MEMORY)
{
- pOutput->pBuffers[token_idx].pvBuffer = HeapAlloc(GetProcessHeap(), 0, bin_len);
+ pOutput->pBuffers[token_idx].pvBuffer = heap_alloc(bin_len);
pOutput->pBuffers[token_idx].cbBuffer = bin_len;
}
else if (pOutput->pBuffers[token_idx].cbBuffer < bin_len)
@@ -955,9 +884,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
TRACE("Failed to decode session key\n");
}
TRACE("Session key is %s\n", debugstr_a(buffer+3));
- HeapFree(GetProcessHeap(), 0, helper->session_key);
- helper->session_key = HeapAlloc(GetProcessHeap(), 0, bin_len);
- if(!helper->session_key)
+ heap_free(helper->session_key);
+ if (!(helper->session_key = heap_alloc(bin_len)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto isc_end;
@@ -980,12 +908,12 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
}
isc_end:
- HeapFree(GetProcessHeap(), 0, username);
- HeapFree(GetProcessHeap(), 0, domain);
- HeapFree(GetProcessHeap(), 0, password);
- HeapFree(GetProcessHeap(), 0, want_flags);
- HeapFree(GetProcessHeap(), 0, buffer);
- HeapFree(GetProcessHeap(), 0, bin);
+ heap_free(username);
+ heap_free(domain);
+ heap_free(password);
+ heap_free(want_flags);
+ heap_free(buffer);
+ heap_free(bin);
return ret;
}
@@ -1005,21 +933,18 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(
debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
- if(pszTargetName != NULL)
+ if (pszTargetName)
{
- int target_size = MultiByteToWideChar(CP_ACP, 0, pszTargetName,
- strlen(pszTargetName)+1, NULL, 0);
- target = HeapAlloc(GetProcessHeap(), 0, target_size *
- sizeof(SEC_WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pszTargetName, strlen(pszTargetName)+1,
- target, target_size);
+ int target_size = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0);
+ if (!(target = heap_alloc(target_size * sizeof(SEC_WCHAR)))) return SEC_E_INSUFFICIENT_MEMORY;
+ MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target, target_size);
}
ret = ntlm_InitializeSecurityContextW(phCredential, phContext, target,
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry);
- HeapFree(GetProcessHeap(), 0, target);
+ heap_free(target);
return ret;
}
@@ -1043,8 +968,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
ptsExpiry);
- buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(char) * NTLM_MAX_BUF);
- bin = HeapAlloc(GetProcessHeap(),0, sizeof(BYTE) * NTLM_MAX_BUF);
+ buffer = heap_alloc(sizeof(char) * NTLM_MAX_BUF);
+ bin = heap_alloc(sizeof(BYTE) * NTLM_MAX_BUF);
if(TargetDataRep == SECURITY_NETWORK_DREP){
TRACE("Using SECURITY_NETWORK_DREP\n");
@@ -1101,8 +1026,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
helper->mode = NTLM_SERVER;
/* Handle all the flags */
- want_flags = HeapAlloc(GetProcessHeap(), 0, 73);
- if(want_flags == NULL)
+ if (!(want_flags = heap_alloc(73)))
{
TRACE("Failed to allocate memory for the want_flags!\n");
ret = SEC_E_INSUFFICIENT_MEMORY;
@@ -1335,9 +1259,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
if(strncmp(buffer, "BH ", 3) == 0)
{
TRACE("Helper sent %s\n", debugstr_a(buffer+3));
- HeapFree(GetProcessHeap(), 0, helper->session_key);
- helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
- if (!helper->session_key)
+ heap_free(helper->session_key);
+ if (!(helper->session_key = heap_alloc(16)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto asc_end;
@@ -1353,9 +1276,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
TRACE("Failed to decode session key\n");
}
TRACE("Session key is %s\n", debugstr_a(buffer+3));
- HeapFree(GetProcessHeap(), 0, helper->session_key);
- helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
- if(!helper->session_key)
+ heap_free(helper->session_key);
+ if (!(helper->session_key = heap_alloc(16)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto asc_end;
@@ -1372,9 +1294,9 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
phNewContext->dwLower = (ULONG_PTR)helper;
asc_end:
- HeapFree(GetProcessHeap(), 0, want_flags);
- HeapFree(GetProcessHeap(), 0, buffer);
- HeapFree(GetProcessHeap(), 0, bin);
+ heap_free(want_flags);
+ heap_free(buffer);
+ heap_free(bin);
return ret;
}
@@ -1411,10 +1333,10 @@ SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContext)
SECUR32_arc4Cleanup(helper->crypt.ntlm.a4i);
SECUR32_arc4Cleanup(helper->crypt.ntlm2.send_a4i);
SECUR32_arc4Cleanup(helper->crypt.ntlm2.recv_a4i);
- HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.send_sign_key);
- HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.send_seal_key);
- HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.recv_sign_key);
- HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.recv_seal_key);
+ heap_free(helper->crypt.ntlm2.send_sign_key);
+ heap_free(helper->crypt.ntlm2.send_seal_key);
+ heap_free(helper->crypt.ntlm2.recv_sign_key);
+ heap_free(helper->crypt.ntlm2.recv_seal_key);
cleanup_helper(helper);
@@ -1473,7 +1395,7 @@ static SecPkgInfoW *build_package_infoW( const SecPkgInfoW *info )
DWORD size_name = (strlenW(info->Name) + 1) * sizeof(WCHAR);
DWORD size_comment = (strlenW(info->Comment) + 1) * sizeof(WCHAR);
- if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
+ if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@@ -1490,7 +1412,7 @@ static SecPkgInfoA *build_package_infoA( const SecPkgInfoA *info )
SecPkgInfoA *ret;
DWORD size_name = strlen(info->Name) + 1, size_comment = strlen(info->Comment) + 1;
- if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
+ if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@@ -1822,7 +1744,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
helper = (PNegoHelper)phContext->dwLower;
TRACE("Negotiated flags: 0x%08x\n", helper->neg_flags);
- local_buff = HeapAlloc(GetProcessHeap(), 0, pMessage->cBuffers * sizeof(SecBuffer));
+ local_buff = heap_alloc(pMessage->cBuffers * sizeof(SecBuffer));
local_desc.ulVersion = SECBUFFER_VERSION;
local_desc.cBuffers = pMessage->cBuffers;
@@ -1853,8 +1775,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
else
ret = SEC_E_OK;
- HeapFree(GetProcessHeap(), 0, local_buff);
-
+ heap_free(local_buff);
return ret;
}
@@ -1864,24 +1785,19 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
*/
SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle phCredential)
{
- SECURITY_STATUS ret;
-
- if(phCredential){
+ if (phCredential)
+ {
PNtlmCredentials ntlm_cred = (PNtlmCredentials) phCredential->dwLower;
phCredential->dwUpper = 0;
phCredential->dwLower = 0;
- if (ntlm_cred->password)
- memset(ntlm_cred->password, 0, ntlm_cred->pwlen);
- HeapFree(GetProcessHeap(), 0, ntlm_cred->password);
- HeapFree(GetProcessHeap(), 0, ntlm_cred->username_arg);
- HeapFree(GetProcessHeap(), 0, ntlm_cred->domain_arg);
- HeapFree(GetProcessHeap(), 0, ntlm_cred);
- ret = SEC_E_OK;
+ if (ntlm_cred->password) memset(ntlm_cred->password, 0, ntlm_cred->pwlen);
+ heap_free(ntlm_cred->password);
+ heap_free(ntlm_cred->username_arg);
+ heap_free(ntlm_cred->domain_arg);
+ heap_free(ntlm_cred);
}
- else
- ret = SEC_E_OK;
-
- return ret;
+
+ return SEC_E_OK;
}
/***********************************************************************
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 88b6521a7d..90b9782190 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -97,7 +97,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
{
/* Grow the table */
SIZE_T new_size = schan_handle_table_size + (schan_handle_table_size >> 1);
- struct schan_handle *new_table = HeapReAlloc(GetProcessHeap(), 0, schan_handle_table, new_size * sizeof(*schan_handle_table));
+ struct schan_handle *new_table = heap_realloc(schan_handle_table, new_size * sizeof(*schan_handle_table));
if (!new_table)
{
ERR("Failed to grow the handle table\n");
@@ -423,7 +423,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
/* For now, the only thing I'm interested in is the direction of the
* connection, so just store it.
*/
- creds = HeapAlloc(GetProcessHeap(), 0, sizeof(*creds));
+ creds = heap_alloc(sizeof(*creds));
if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
@@ -450,7 +450,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return st;
fail:
- HeapFree(GetProcessHeap(), 0, creds);
+ heap_free(creds);
return SEC_E_INTERNAL_ERROR;
}
@@ -469,14 +469,14 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
ULONG_PTR handle;
struct schan_credentials *creds;
- creds = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*creds));
+ creds = heap_alloc_zero(sizeof(*creds));
if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
creds->credential_use = SECPKG_CRED_INBOUND;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == SCHAN_INVALID_HANDLE)
{
- HeapFree(GetProcessHeap(), 0, creds);
+ heap_free(creds);
return SEC_E_INTERNAL_ERROR;
}
@@ -540,7 +540,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if (creds->credential_use == SECPKG_CRED_OUTBOUND)
schan_imp_free_certificate_credentials(creds);
- HeapFree(GetProcessHeap(), 0, creds);
+ heap_free(creds);
return SEC_E_OK;
}
@@ -581,9 +581,9 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi
while (new_size < min_size) new_size *= 2;
if (b->pvBuffer)
- new_data = HeapReAlloc(GetProcessHeap(), 0, b->pvBuffer, new_size);
+ new_data = heap_realloc(b->pvBuffer, new_size);
else
- new_data = HeapAlloc(GetProcessHeap(), 0, new_size);
+ new_data = heap_alloc(new_size);
if (!new_data)
{
@@ -815,21 +815,21 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INVALID_HANDLE;
}
- ctx = HeapAlloc(GetProcessHeap(), 0, sizeof(*ctx));
+ ctx = heap_alloc(sizeof(*ctx));
if (!ctx) return SEC_E_INSUFFICIENT_MEMORY;
ctx->cert = NULL;
handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX);
if (handle == SCHAN_INVALID_HANDLE)
{
- HeapFree(GetProcessHeap(), 0, ctx);
+ heap_free(ctx);
return SEC_E_INTERNAL_ERROR;
}
if (!schan_imp_create_session(&ctx->session, cred))
{
schan_free_handle(handle, SCHAN_HANDLE_CTX);
- HeapFree(GetProcessHeap(), 0, ctx);
+ heap_free(ctx);
return SEC_E_INTERNAL_ERROR;
}
@@ -839,13 +839,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (pszTargetName && *pszTargetName)
{
UINT len = WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, NULL, 0, NULL, NULL );
- char *target = HeapAlloc( GetProcessHeap(), 0, len );
+ char *target = heap_alloc( len );
if (target)
{
WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL );
schan_imp_set_session_target( ctx->session, target );
- HeapFree( GetProcessHeap(), 0, target );
+ heap_free( target );
}
}
phNewContext->dwLower = handle;
@@ -950,7 +950,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
if (pszTargetName)
{
INT len = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0);
- target_name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*target_name));
+ if (!(target_name = heap_alloc(len * sizeof(*target_name)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target_name, len);
}
@@ -958,8 +958,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry);
- HeapFree(GetProcessHeap(), 0, target_name);
-
+ heap_free(target_name);
return ret;
}
@@ -1104,7 +1103,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
return GetLastError();
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + hash_size;
- bindings->Bindings = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
+ bindings->Bindings = heap_alloc_zero(bindings->BindingsLength);
if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY;
@@ -1232,7 +1231,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
buffer = &message->pBuffers[idx];
data_size = buffer->cbBuffer;
- data = HeapAlloc(GetProcessHeap(), 0, data_size);
+ data = heap_alloc(data_size);
memcpy(data, buffer->pvBuffer, data_size);
if (schan_find_sec_buffer_idx(message, 0, SECBUFFER_STREAM_HEADER) != -1)
@@ -1250,7 +1249,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
b = &ctx->transport.out;
b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset;
- HeapFree(GetProcessHeap(), 0, data);
+ heap_free(data);
TRACE("Returning %#x.\n", status);
@@ -1365,7 +1364,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
}
data_size = expected_size - 5;
- data = HeapAlloc(GetProcessHeap(), 0, data_size);
+ data = heap_alloc(data_size);
init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size;
@@ -1380,7 +1379,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
if (status != SEC_E_OK)
{
- HeapFree(GetProcessHeap(), 0, data);
+ heap_free(data);
ERR("Returning %x\n", status);
return status;
}
@@ -1394,7 +1393,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
TRACE("Received %ld bytes\n", received);
memcpy(buf_ptr + 5, data, received);
- HeapFree(GetProcessHeap(), 0, data);
+ heap_free(data);
schan_decrypt_fill_buffer(message, SECBUFFER_DATA,
buf_ptr + 5, received);
@@ -1426,7 +1425,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
if (ctx->cert)
CertFreeCertificateContext(ctx->cert);
schan_imp_dispose_session(ctx->session);
- HeapFree(GetProcessHeap(), 0, ctx);
+ heap_free(ctx);
return SEC_E_OK;
}
@@ -1526,7 +1525,7 @@ void SECUR32_initSchannelSP(void)
if (!schan_imp_init())
return;
- schan_handle_table = HeapAlloc(GetProcessHeap(), 0, 64 * sizeof(*schan_handle_table));
+ schan_handle_table = heap_alloc(64 * sizeof(*schan_handle_table));
if (!schan_handle_table)
{
ERR("Failed to allocate schannel handle table.\n");
@@ -1546,7 +1545,7 @@ void SECUR32_initSchannelSP(void)
return;
fail:
- HeapFree(GetProcessHeap(), 0, schan_handle_table);
+ heap_free(schan_handle_table);
schan_handle_table = NULL;
schan_imp_deinit();
return;
@@ -1566,7 +1565,7 @@ void SECUR32_deinitSchannelSP(void)
{
struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX);
schan_imp_dispose_session(ctx->session);
- HeapFree(GetProcessHeap(), 0, ctx);
+ heap_free(ctx);
}
}
i = schan_handle_count;
@@ -1577,10 +1576,10 @@ void SECUR32_deinitSchannelSP(void)
struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
schan_imp_free_certificate_credentials(cred);
- HeapFree(GetProcessHeap(), 0, cred);
+ heap_free(cred);
}
}
- HeapFree(GetProcessHeap(), 0, schan_handle_table);
+ heap_free(schan_handle_table);
schan_imp_deinit();
}
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
index 015de9286e..a2f42615e1 100644
--- a/dlls/secur32/schannel_macosx.c
+++ b/dlls/secur32/schannel_macosx.c
@@ -739,7 +739,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
TRACE("(%p)\n", session);
- s = HeapAlloc(GetProcessHeap(), 0, sizeof(*s));
+ s = heap_alloc(sizeof(*s));
if (!s)
return FALSE;
@@ -793,7 +793,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
return TRUE;
fail:
- HeapFree(GetProcessHeap(), 0, s);
+ heap_free(s);
return FALSE;
}
@@ -808,7 +808,7 @@ void schan_imp_dispose_session(schan_imp_session session)
if (status != noErr)
ERR("Failed to dispose of session context: %d\n", status);
DeleteCriticalSection(&s->cs);
- HeapFree(GetProcessHeap(), 0, s);
+ heap_free(s);
}
void schan_imp_set_session_transport(schan_imp_session session,
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index f7b1ec2d98..4408e7cf83 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -178,7 +178,7 @@ static PWSTR SECUR32_strdupW(PCWSTR str)
if (str)
{
- ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR));
+ ret = heap_alloc((lstrlenW(str) + 1) * sizeof(WCHAR));
if (ret)
lstrcpyW(ret, str);
}
@@ -197,7 +197,7 @@ PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
if (charsNeeded)
{
- ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR));
+ ret = heap_alloc(charsNeeded * sizeof(WCHAR));
if (ret)
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
}
@@ -220,7 +220,7 @@ PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str)
if (charsNeeded)
{
- ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded);
+ ret = heap_alloc(charsNeeded);
if (ret)
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
NULL, NULL);
@@ -406,7 +406,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if (!providerTable)
{
- providerTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProviderTable));
+ providerTable = heap_alloc(sizeof(SecureProviderTable));
if (!providerTable)
{
LeaveCriticalSection(&cs);
@@ -416,7 +416,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
list_init(&providerTable->table);
}
- ret = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProvider));
+ ret = heap_alloc(sizeof(SecureProvider));
if (!ret)
{
LeaveCriticalSection(&cs);
@@ -455,7 +455,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
if (!packageTable)
{
- packageTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackageTable));
+ packageTable = heap_alloc(sizeof(SecurePackageTable));
if (!packageTable)
{
LeaveCriticalSection(&cs);
@@ -468,7 +468,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
for (i = 0; i < toAdd; i++)
{
- SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage));
+ SecurePackage *package = heap_alloc(sizeof(SecurePackage));
if (!package)
continue;
@@ -685,12 +685,12 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table,
SecurePackage, entry)
{
- HeapFree(GetProcessHeap(), 0, package->infoW.Name);
- HeapFree(GetProcessHeap(), 0, package->infoW.Comment);
- HeapFree(GetProcessHeap(), 0, package);
+ heap_free(package->infoW.Name);
+ heap_free(package->infoW.Comment);
+ heap_free(package);
}
- HeapFree(GetProcessHeap(), 0, packageTable);
+ heap_free(packageTable);
packageTable = NULL;
}
@@ -700,13 +700,13 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table,
SecureProvider, entry)
{
- HeapFree(GetProcessHeap(), 0, provider->moduleName);
+ heap_free(provider->moduleName);
if (provider->lib)
FreeLibrary(provider->lib);
- HeapFree(GetProcessHeap(), 0, provider);
+ heap_free(provider);
}
- HeapFree(GetProcessHeap(), 0, providerTable);
+ heap_free(providerTable);
providerTable = NULL;
}
@@ -723,8 +723,7 @@ static void SECUR32_freeProviders(void)
*/
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
{
- HeapFree(GetProcessHeap(), 0, pv);
-
+ heap_free(pv);
return SEC_E_OK;
}
@@ -756,7 +755,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
}
if (bytesNeeded)
{
- *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
ULONG i = 0;
@@ -821,7 +820,7 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages,
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
-1, NULL, 0, NULL, NULL);
}
- ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ ret = heap_alloc(bytesNeeded);
if (ret)
{
PSTR nextString;
@@ -924,7 +923,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
- bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
+ bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -938,7 +937,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
}
else
*nSize = sizeW;
- HeapFree(GetProcessHeap(), 0, bufferW);
+ heap_free(bufferW);
return rc;
}
@@ -1081,7 +1080,7 @@ BOOLEAN WINAPI GetUserNameExA(
ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
- bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
+ bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -1104,7 +1103,7 @@ BOOLEAN WINAPI GetUserNameExA(
}
else
*nSize = sizeW;
- HeapFree(GetProcessHeap(), 0, bufferW);
+ heap_free(bufferW);
return rc;
}
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 973b75c699..268e77ee2e 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <limits.h>
+#include "wine/heap.h"
#include "wine/list.h"
#include "schannel.h"
diff --git a/dlls/secur32/thunks.c b/dlls/secur32/thunks.c
index 33f8bb1ce5..09b20d54ab 100644
--- a/dlls/secur32/thunks.c
+++ b/dlls/secur32/thunks.c
@@ -76,8 +76,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
ret = AcquireCredentialsHandleA(principal, package, fCredentialsUse,
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential,
ptsExpiry);
- HeapFree(GetProcessHeap(), 0, principal);
- HeapFree(GetProcessHeap(), 0, package);
+ heap_free(principal);
+ heap_free(package);
}
else
ret = SEC_E_SECPKG_NOT_FOUND;
@@ -259,7 +259,7 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(
phCredential, phContext, target, fContextReq, Reserved1,
TargetDataRep, pInput, Reserved2, phNewContext, pOutput,
pfContextAttr, ptsExpiry);
- HeapFree(GetProcessHeap(), 0, target);
+ heap_free(target);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -337,8 +337,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials,
ret = package->provider->fnTableA.AddCredentialsA(
cred, szPrincipal, szPackage, fCredentialUse, pAuthData,
pGetKeyFn, pvGetKeyArgument, ptsExpiry);
- HeapFree(GetProcessHeap(), 0, szPrincipal);
- HeapFree(GetProcessHeap(), 0, szPackage);
+ heap_free(szPrincipal);
+ heap_free(szPackage);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -372,7 +372,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
- ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ ret = heap_alloc(bytesNeeded);
if (ret)
{
PSTR nextString = (PSTR)((PBYTE)ret + sizeof(SecPkgInfoA));
@@ -597,7 +597,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
NULL, 0);
bytesNeeded += commentLen * sizeof(WCHAR);
}
- ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ ret = heap_alloc(bytesNeeded);
if (ret)
{
PWSTR nextString = (PWSTR)((PBYTE)ret + sizeof(SecPkgInfoW));
@@ -894,6 +894,6 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(
TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
phContext);
ret = ImportSecurityContextA(package, pPackedContext, Token, phContext);
- HeapFree(GetProcessHeap(), 0, package);
+ heap_free(package);
return ret;
}
diff --git a/dlls/secur32/util.c b/dlls/secur32/util.c
index ab52251281..acb6290505 100644
--- a/dlls/secur32/util.c
+++ b/dlls/secur32/util.c
@@ -157,10 +157,10 @@ static void SECUR32_CalcNTLM2Subkey(const BYTE *session_key, const char *magic,
/* This assumes we do have a valid NTLM2 user session key */
SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
{
- helper->crypt.ntlm2.send_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
- helper->crypt.ntlm2.send_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
- helper->crypt.ntlm2.recv_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
- helper->crypt.ntlm2.recv_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
+ helper->crypt.ntlm2.send_sign_key = heap_alloc(16);
+ helper->crypt.ntlm2.send_seal_key = heap_alloc(16);
+ helper->crypt.ntlm2.recv_sign_key = heap_alloc(16);
+ helper->crypt.ntlm2.recv_seal_key = heap_alloc(16);
if(helper->mode == NTLM_CLIENT)
{
@@ -190,7 +190,7 @@ SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
arc4_info *SECUR32_arc4Alloc(void)
{
- arc4_info *a4i = HeapAlloc(GetProcessHeap(), 0, sizeof(arc4_info));
+ arc4_info *a4i = heap_alloc(sizeof(arc4_info));
return a4i;
}
@@ -247,5 +247,5 @@ void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length)
void SECUR32_arc4Cleanup(arc4_info *a4i)
{
- HeapFree(GetProcessHeap(), 0, a4i);
+ heap_free(a4i);
}
diff --git a/dlls/secur32/wrapper.c b/dlls/secur32/wrapper.c
index dba675422d..4278c03f1c 100644
--- a/dlls/secur32/wrapper.c
+++ b/dlls/secur32/wrapper.c
@@ -41,7 +41,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
if (phSec && package && realHandle)
{
- PSecHandle newSec = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle));
+ PSecHandle newSec = heap_alloc(sizeof(SecHandle));
if (newSec)
{
@@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle(
ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
else
ret = SEC_E_INVALID_HANDLE;
- HeapFree(GetProcessHeap(), 0, cred);
+ heap_free(cred);
}
else
ret = SEC_E_INVALID_HANDLE;
@@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
else
ret = SEC_E_INVALID_HANDLE;
- HeapFree(GetProcessHeap(), 0, ctxt);
+ heap_free(ctxt);
}
else
ret = SEC_E_INVALID_HANDLE;
@@ -713,7 +713,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
package->infoW.Comment, -1, NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
- *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
@@ -775,7 +775,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
commentLen = lstrlenW(package->infoW.Comment) + 1;
bytesNeeded += commentLen * sizeof(WCHAR);
}
- *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
+ *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
--
2.11.0
1
0
[PATCH 3/4] secur32: Forward to either Kerberos or NTLM from the Negotiate provider.
by Hans Leidekker 14 Feb '18
by Hans Leidekker 14 Feb '18
14 Feb '18
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/negotiate.c | 351 ++++++++++++++++++++++++++++++-----------
dlls/secur32/tests/negotiate.c | 3 -
2 files changed, 256 insertions(+), 98 deletions(-)
diff --git a/dlls/secur32/negotiate.c b/dlls/secur32/negotiate.c
index bf16258fc2..5000f0f953 100644
--- a/dlls/secur32/negotiate.c
+++ b/dlls/secur32/negotiate.c
@@ -15,9 +15,6 @@
* 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
- *
- * This file implements a Negotiate provider that simply forwards to
- * the NTLM provider.
*/
#include <stdarg.h>
@@ -53,6 +50,14 @@ static SECURITY_STATUS SEC_ENTRY nego_QueryCredentialsAttributesW(
return SEC_E_UNSUPPORTED_FUNCTION;
}
+struct sec_handle
+{
+ SecureProvider *krb;
+ SecureProvider *ntlm;
+ SecHandle handle_krb;
+ SecHandle handle_ntlm;
+};
+
/***********************************************************************
* AcquireCredentialsHandleW
*/
@@ -62,21 +67,45 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry )
{
static SEC_WCHAR ntlmW[] = {'N','T','L','M',0};
- SECURITY_STATUS ret;
+ static SEC_WCHAR kerberosW[] = {'K','e','r','b','e','r','o','s',0};
+ SECURITY_STATUS ret = SEC_E_NO_CREDENTIALS;
+ struct sec_handle *cred;
+ SecurePackage *package;
TRACE("%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p\n",
debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
- FIXME("forwarding to NTLM\n");
- ret = ntlm_AcquireCredentialsHandleW( pszPrincipal, ntlmW, fCredentialUse,
- pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument,
- phCredential, ptsExpiry );
- if (ret == SEC_E_OK)
+ if (!pszPackage) return SEC_E_SECPKG_NOT_FOUND;
+ if (!(cred = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
+
+ if ((package = SECUR32_findPackageW( kerberosW )))
{
- NtlmCredentials *cred = (NtlmCredentials *)phCredential->dwLower;
- cred->no_cached_credentials = (pAuthData == NULL);
+ ret = package->provider->fnTableW.AcquireCredentialsHandleW( pszPrincipal, kerberosW,
+ fCredentialUse, pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, &cred->handle_krb, ptsExpiry );
+ if (ret == SEC_E_OK) cred->krb = package->provider;
}
+
+ if ((package = SECUR32_findPackageW( ntlmW )))
+ {
+ ret = package->provider->fnTableW.AcquireCredentialsHandleW( pszPrincipal, ntlmW,
+ fCredentialUse, pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, &cred->handle_ntlm, ptsExpiry );
+ if (ret == SEC_E_OK)
+ {
+ NtlmCredentials *ntlm_cred = (NtlmCredentials *)cred->handle_ntlm.dwLower;
+ ntlm_cred->no_cached_credentials = (pAuthData == NULL);
+ cred->ntlm = package->provider;
+ }
+ }
+
+ if (cred->krb || cred->ntlm)
+ {
+ phCredential->dwLower = (ULONG_PTR)cred;
+ phCredential->dwUpper = 0;
+ return SEC_E_OK;
+ }
+
+ HeapFree( GetProcessHeap(), 0, cred );
return ret;
}
@@ -173,15 +202,58 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry )
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *handle = NULL, *ctxt, *new_ctxt = NULL, *cred = NULL;
+
TRACE("%p, %p, %s, 0x%08x, %u, %u, %p, %u, %p, %p, %p, %p\n",
phCredential, phContext, debugstr_w(pszTargetName), fContextReq,
Reserved1, TargetDataRep, pInput, Reserved1, phNewContext, pOutput,
pfContextAttr, ptsExpiry);
- return ntlm_InitializeSecurityContextW( phCredential, phContext, pszTargetName,
- fContextReq, Reserved1, TargetDataRep,
- pInput, Reserved2, phNewContext,
- pOutput, pfContextAttr, ptsExpiry );
+ if (phContext)
+ {
+ handle = ctxt = (struct sec_handle *)phContext->dwLower;
+ }
+ else if (phCredential)
+ {
+ handle = cred = (struct sec_handle *)phCredential->dwLower;
+ if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
+ return SEC_E_INSUFFICIENT_MEMORY;
+ ctxt->krb = cred->krb;
+ ctxt->ntlm = cred->ntlm;
+ }
+ if (!handle) return SEC_E_INVALID_HANDLE;
+
+ if (handle->krb)
+ {
+ ret = handle->krb->fnTableW.InitializeSecurityContextW( phCredential ? &cred->handle_krb : NULL,
+ phContext ? &ctxt->handle_krb : NULL, pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
+ Reserved2, phNewContext ? &ctxt->handle_krb : NULL, pOutput, pfContextAttr, ptsExpiry );
+ if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
+ {
+ ctxt->ntlm = NULL;
+ phNewContext->dwLower = (ULONG_PTR)ctxt;
+ phNewContext->dwUpper = 0;
+ if (new_ctxt == ctxt) new_ctxt = NULL;
+ }
+ }
+
+ if (ret != SEC_E_OK && ret != SEC_I_CONTINUE_NEEDED && handle->ntlm)
+ {
+ ret = handle->ntlm->fnTableW.InitializeSecurityContextW( phCredential ? &cred->handle_ntlm : NULL,
+ phContext ? &ctxt->handle_ntlm : NULL, pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
+ Reserved2, phNewContext ? &ctxt->handle_ntlm : NULL, pOutput, pfContextAttr, ptsExpiry );
+ if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
+ {
+ ctxt->krb = NULL;
+ phNewContext->dwLower = (ULONG_PTR)ctxt;
+ phNewContext->dwUpper = 0;
+ if (new_ctxt == ctxt) new_ctxt = NULL;
+ }
+ }
+
+ HeapFree( GetProcessHeap(), 0, new_ctxt );
+ return ret;
}
/***********************************************************************
@@ -223,13 +295,57 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *handle = NULL, *ctxt, *new_ctxt = NULL, *cred = NULL;
+
TRACE("%p, %p, %p, 0x%08x, %u, %p, %p, %p, %p\n", phCredential, phContext,
pInput, fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
ptsExpiry);
- return ntlm_AcceptSecurityContext( phCredential, phContext, pInput,
- fContextReq, TargetDataRep, phNewContext,
- pOutput, pfContextAttr, ptsExpiry );
+ if (phContext)
+ {
+ handle = ctxt = (struct sec_handle *)phContext->dwLower;
+ }
+ else if (phCredential)
+ {
+ handle = cred = (struct sec_handle *)phCredential->dwLower;
+ if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
+ return SEC_E_INSUFFICIENT_MEMORY;
+ ctxt->krb = cred->krb;
+ ctxt->ntlm = cred->ntlm;
+ }
+ if (!handle) return SEC_E_INVALID_HANDLE;
+
+ if (handle->krb)
+ {
+ ret = handle->krb->fnTableW.AcceptSecurityContext( phCredential ? &cred->handle_krb : NULL,
+ phContext ? &ctxt->handle_krb : NULL, pInput, fContextReq, TargetDataRep,
+ phNewContext ? &ctxt->handle_krb : NULL, pOutput, pfContextAttr, ptsExpiry );
+ if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
+ {
+ ctxt->ntlm = NULL;
+ phNewContext->dwLower = (ULONG_PTR)ctxt;
+ phNewContext->dwUpper = 0;
+ if (new_ctxt == ctxt) new_ctxt = NULL;
+ }
+ }
+
+ if (ret != SEC_E_OK && ret != SEC_I_CONTINUE_NEEDED && handle->ntlm)
+ {
+ ret = handle->ntlm->fnTableW.AcceptSecurityContext( phCredential ? &cred->handle_ntlm : NULL,
+ phContext ? &ctxt->handle_ntlm : NULL, pInput, fContextReq, TargetDataRep,
+ phNewContext ? &ctxt->handle_ntlm : NULL, pOutput, pfContextAttr, ptsExpiry );
+ if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
+ {
+ ctxt->krb = NULL;
+ phNewContext->dwLower = (ULONG_PTR)ctxt;
+ phNewContext->dwUpper = 0;
+ if (new_ctxt == ctxt) new_ctxt = NULL;
+ }
+ }
+
+ HeapFree( GetProcessHeap(), 0, new_ctxt );
+ return ret;
}
/***********************************************************************
@@ -238,17 +354,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
static SECURITY_STATUS SEC_ENTRY nego_CompleteAuthToken(PCtxtHandle phContext,
PSecBufferDesc pToken)
{
- SECURITY_STATUS ret;
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
TRACE("%p %p\n", phContext, pToken);
- if (phContext)
- {
- ret = SEC_E_UNSUPPORTED_FUNCTION;
- }
- else
- {
- ret = SEC_E_INVALID_HANDLE;
- }
+
+ if (phContext) ret = SEC_E_UNSUPPORTED_FUNCTION;
return ret;
}
@@ -257,9 +367,25 @@ static SECURITY_STATUS SEC_ENTRY nego_CompleteAuthToken(PCtxtHandle phContext,
*/
static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContext)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p\n", phContext);
- return ntlm_DeleteSecurityContext( phContext );
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
+ {
+ ret = ctxt->krb->fnTableW.DeleteSecurityContext( &ctxt->handle_krb );
+ }
+ else if (ctxt->ntlm)
+ {
+ ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm );
+ }
+ TRACE( "freeing %p\n", ctxt );
+ HeapFree( GetProcessHeap(), 0, ctxt );
+ return ret;
}
/***********************************************************************
@@ -268,17 +394,11 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
static SECURITY_STATUS SEC_ENTRY nego_ApplyControlToken(PCtxtHandle phContext,
PSecBufferDesc pInput)
{
- SECURITY_STATUS ret;
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
TRACE("%p %p\n", phContext, pInput);
- if (phContext)
- {
- ret = SEC_E_UNSUPPORTED_FUNCTION;
- }
- else
- {
- ret = SEC_E_INVALID_HANDLE;
- }
+
+ if (phContext) ret = SEC_E_UNSUPPORTED_FUNCTION;
return ret;
}
@@ -288,60 +408,48 @@ static SECURITY_STATUS SEC_ENTRY nego_ApplyControlToken(PCtxtHandle phContext,
static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesW(
PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, %u, %p\n", phContext, ulAttribute, pBuffer);
- switch (ulAttribute)
- {
- case SECPKG_ATTR_SIZES:
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
{
- SecPkgContext_Sizes *sizes = (SecPkgContext_Sizes *)pBuffer;
- sizes->cbMaxToken = 2888;
- sizes->cbMaxSignature = 16;
- sizes->cbSecurityTrailer = 16;
- sizes->cbBlockSize = 0;
- return SEC_E_OK;
+ ret = ctxt->krb->fnTableW.QueryContextAttributesW( &ctxt->handle_krb, ulAttribute, pBuffer );
}
- case SECPKG_ATTR_NEGOTIATION_INFO:
+ else if (ctxt->ntlm)
{
- SecPkgContext_NegotiationInfoW *info = (SecPkgContext_NegotiationInfoW *)pBuffer;
- info->PackageInfo = ntlm_package_infoW;
- info->NegotiationState = SECPKG_NEGOTIATION_COMPLETE;
- return SEC_E_OK;
- }
- default:
- return ntlm_QueryContextAttributesW( phContext, ulAttribute, pBuffer );
+ ret = ctxt->ntlm->fnTableW.QueryContextAttributesW( &ctxt->handle_ntlm, ulAttribute, pBuffer );
}
+ return ret;
}
/***********************************************************************
* QueryContextAttributesA
*/
static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesA(PCtxtHandle phContext,
- ULONG ulAttribute, void *pBuffer)
+ ULONG ulAttribute, void *pBuffer)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, %u, %p\n", phContext, ulAttribute, pBuffer);
- switch (ulAttribute)
- {
- case SECPKG_ATTR_SIZES:
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
{
- SecPkgContext_Sizes *sizes = (SecPkgContext_Sizes *)pBuffer;
- sizes->cbMaxToken = 2888;
- sizes->cbMaxSignature = 16;
- sizes->cbSecurityTrailer = 16;
- sizes->cbBlockSize = 0;
- return SEC_E_OK;
+ ret = ctxt->krb->fnTableA.QueryContextAttributesA( &ctxt->handle_krb, ulAttribute, pBuffer );
}
- case SECPKG_ATTR_NEGOTIATION_INFO:
+ else if (ctxt->ntlm)
{
- SecPkgContext_NegotiationInfoA *info = (SecPkgContext_NegotiationInfoA *)pBuffer;
- info->PackageInfo = ntlm_package_infoA;
- info->NegotiationState = SECPKG_NEGOTIATION_COMPLETE;
- return SEC_E_OK;
- }
- default:
- return ntlm_QueryContextAttributesA( phContext, ulAttribute, pBuffer );
+ ret = ctxt->ntlm->fnTableA.QueryContextAttributesA( &ctxt->handle_ntlm, ulAttribute, pBuffer );
}
+ return ret;
}
/***********************************************************************
@@ -349,17 +457,11 @@ static SECURITY_STATUS SEC_ENTRY nego_QueryContextAttributesA(PCtxtHandle phCont
*/
static SECURITY_STATUS SEC_ENTRY nego_ImpersonateSecurityContext(PCtxtHandle phContext)
{
- SECURITY_STATUS ret;
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
TRACE("%p\n", phContext);
- if (phContext)
- {
- ret = SEC_E_UNSUPPORTED_FUNCTION;
- }
- else
- {
- ret = SEC_E_INVALID_HANDLE;
- }
+
+ if (phContext) ret = SEC_E_UNSUPPORTED_FUNCTION;
return ret;
}
@@ -368,17 +470,11 @@ static SECURITY_STATUS SEC_ENTRY nego_ImpersonateSecurityContext(PCtxtHandle phC
*/
static SECURITY_STATUS SEC_ENTRY nego_RevertSecurityContext(PCtxtHandle phContext)
{
- SECURITY_STATUS ret;
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
TRACE("%p\n", phContext);
- if (phContext)
- {
- ret = SEC_E_UNSUPPORTED_FUNCTION;
- }
- else
- {
- ret = SEC_E_INVALID_HANDLE;
- }
+
+ if (phContext) ret = SEC_E_UNSUPPORTED_FUNCTION;
return ret;
}
@@ -388,9 +484,23 @@ static SECURITY_STATUS SEC_ENTRY nego_RevertSecurityContext(PCtxtHandle phContex
static SECURITY_STATUS SEC_ENTRY nego_MakeSignature(PCtxtHandle phContext,
ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, 0x%08x, %p, %u\n", phContext, fQOP, pMessage, MessageSeqNo);
- return ntlm_MakeSignature( phContext, fQOP, pMessage, MessageSeqNo );
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
+ {
+ ret = ctxt->krb->fnTableW.MakeSignature( &ctxt->handle_krb, fQOP, pMessage, MessageSeqNo );
+ }
+ else if (ctxt->ntlm)
+ {
+ ret = ctxt->ntlm->fnTableW.MakeSignature( &ctxt->handle_ntlm, fQOP, pMessage, MessageSeqNo );
+ }
+ return ret;
}
/***********************************************************************
@@ -399,9 +509,23 @@ static SECURITY_STATUS SEC_ENTRY nego_MakeSignature(PCtxtHandle phContext,
static SECURITY_STATUS SEC_ENTRY nego_VerifySignature(PCtxtHandle phContext,
PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, %p, %u, %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
- return ntlm_VerifySignature( phContext, pMessage, MessageSeqNo, pfQOP );
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
+ {
+ ret = ctxt->krb->fnTableW.VerifySignature( &ctxt->handle_krb, pMessage, MessageSeqNo, pfQOP );
+ }
+ else if (ctxt->ntlm)
+ {
+ ret = ctxt->ntlm->fnTableW.VerifySignature( &ctxt->handle_ntlm, pMessage, MessageSeqNo, pfQOP );
+ }
+ return ret;
}
/***********************************************************************
@@ -409,9 +533,18 @@ static SECURITY_STATUS SEC_ENTRY nego_VerifySignature(PCtxtHandle phContext,
*/
static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCredential)
{
+ struct sec_handle *cred;
+
TRACE("%p\n", phCredential);
- return ntlm_FreeCredentialsHandle( phCredential );
+ if (!phCredential) return SEC_E_INVALID_HANDLE;
+
+ cred = (struct sec_handle *)phCredential->dwLower;
+ if (cred->krb) cred->krb->fnTableW.FreeCredentialsHandle( &cred->handle_krb );
+ if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm );
+
+ HeapFree( GetProcessHeap(), 0, cred );
+ return SEC_E_OK;
}
/***********************************************************************
@@ -420,9 +553,23 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden
static SECURITY_STATUS SEC_ENTRY nego_EncryptMessage(PCtxtHandle phContext,
ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, 0x%08x, %p, %u\n", phContext, fQOP, pMessage, MessageSeqNo);
- return ntlm_EncryptMessage( phContext, fQOP, pMessage, MessageSeqNo );
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
+ {
+ ret = ctxt->krb->fnTableW.EncryptMessage( &ctxt->handle_krb, fQOP, pMessage, MessageSeqNo );
+ }
+ else if (ctxt->ntlm)
+ {
+ ret = ctxt->ntlm->fnTableW.EncryptMessage( &ctxt->handle_ntlm, fQOP, pMessage, MessageSeqNo );
+ }
+ return ret;
}
/***********************************************************************
@@ -431,9 +578,23 @@ static SECURITY_STATUS SEC_ENTRY nego_EncryptMessage(PCtxtHandle phContext,
static SECURITY_STATUS SEC_ENTRY nego_DecryptMessage(PCtxtHandle phContext,
PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
{
+ SECURITY_STATUS ret = SEC_E_INVALID_HANDLE;
+ struct sec_handle *ctxt;
+
TRACE("%p, %p, %u, %p\n", phContext, pMessage, MessageSeqNo, pfQOP);
- return ntlm_DecryptMessage( phContext, pMessage, MessageSeqNo, pfQOP );
+ if (!phContext) return SEC_E_INVALID_HANDLE;
+
+ ctxt = (struct sec_handle *)phContext->dwLower;
+ if (ctxt->krb)
+ {
+ ret = ctxt->krb->fnTableW.DecryptMessage( &ctxt->handle_krb, pMessage, MessageSeqNo, pfQOP );
+ }
+ else if (ctxt->ntlm)
+ {
+ ret = ctxt->ntlm->fnTableW.DecryptMessage( &ctxt->handle_ntlm, pMessage, MessageSeqNo, pfQOP );
+ }
+ return ret;
}
static const SecurityFunctionTableA negoTableA = {
diff --git a/dlls/secur32/tests/negotiate.c b/dlls/secur32/tests/negotiate.c
index 2f1228ced2..095aee6cb5 100644
--- a/dlls/secur32/tests/negotiate.c
+++ b/dlls/secur32/tests/negotiate.c
@@ -306,12 +306,9 @@ static void test_authentication(void)
expected = sizeof(*pi) + lstrlenA(pi->Name) + 1 + lstrlenA(pi->Comment) + 1;
got = HeapSize(GetProcessHeap(), 0, pi);
-todo_wine
ok( got == expected, "got %u, expected %u\n", got, expected );
eob = (char *)pi + expected;
-todo_wine
ok( pi->Name + lstrlenA(pi->Name) < eob, "Name doesn't fit into allocated block\n" );
-todo_wine
ok( pi->Comment + lstrlenA(pi->Comment) < eob, "Comment doesn't fit into allocated block\n" );
status = FreeContextBuffer( pi );
--
2.11.0
1
0
[PATCH 2/4] kerberos: Trace returned flags instead of the context handle in kerberos_SpAcceptLsaModeContext.
by Hans Leidekker 14 Feb '18
by Hans Leidekker 14 Feb '18
14 Feb '18
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/kerberos/krb5_ap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/kerberos/krb5_ap.c b/dlls/kerberos/krb5_ap.c
index ea9c687dac..52cbe05da4 100644
--- a/dlls/kerberos/krb5_ap.c
+++ b/dlls/kerberos/krb5_ap.c
@@ -976,7 +976,7 @@ static NTSTATUS NTAPI kerberos_SpAcceptLsaModeContext( LSA_SEC_HANDLE credential
SecBufferDesc *output, ULONG *context_attr, TimeStamp *ts_expiry, BOOLEAN *mapped_context, SecBuffer *context_data )
{
#ifdef SONAME_LIBGSSAPI_KRB5
- OM_uint32 ret, minor_status, ret_flags, expiry_time;
+ OM_uint32 ret, minor_status, ret_flags = 0, expiry_time;
gss_cred_id_t cred_handle;
gss_ctx_id_t ctxt_handle;
gss_buffer_desc input_token, output_token;
@@ -1006,7 +1006,7 @@ static NTSTATUS NTAPI kerberos_SpAcceptLsaModeContext( LSA_SEC_HANDLE credential
ret = pgss_accept_sec_context( &minor_status, &ctxt_handle, cred_handle, &input_token, GSS_C_NO_CHANNEL_BINDINGS,
&target, NULL, &output_token, &ret_flags, &expiry_time, NULL );
- TRACE( "gss_accept_sec_context returned %08x minor status %08x ctxt_handle %p\n", ret, minor_status, ctxt_handle );
+ TRACE( "gss_accept_sec_context returned %08x minor status %08x ret_flags %08x\n", ret, minor_status, ret_flags );
if (GSS_ERROR(ret)) trace_gss_status( ret, minor_status );
if (ret == GSS_S_COMPLETE || ret == GSS_S_CONTINUE_NEEDED)
{
--
2.11.0
1
0