[3/5] webservices: Validate the handle in channel functions.
Hans Leidekker
hans at codeweavers.com
Wed Aug 17 07:24:00 CDT 2016
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/webservices/channel.c | 5 ++++-
dlls/webservices/tests/channel.c | 15 +++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index aba87c0..0277d51 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -188,6 +188,7 @@ HRESULT WINAPI WsGetChannelProperty( WS_CHANNEL *handle, WS_CHANNEL_PROPERTY_ID
TRACE( "%p %u %p %u %p\n", handle, id, buf, size, error );
if (error) FIXME( "ignoring error parameter\n" );
+ if (!handle) return E_INVALIDARG;
return prop_get( channel->prop, channel->prop_count, id, buf, size );
}
@@ -202,6 +203,7 @@ HRESULT WINAPI WsSetChannelProperty( WS_CHANNEL *handle, WS_CHANNEL_PROPERTY_ID
TRACE( "%p %u %p %u\n", handle, id, value, size );
if (error) FIXME( "ignoring error parameter\n" );
+ if (!handle) return E_INVALIDARG;
return prop_set( channel->prop, channel->prop_count, id, value, size );
}
@@ -223,7 +225,7 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
if (error) FIXME( "ignoring error parameter\n" );
if (ctx) FIXME( "ignoring ctx parameter\n" );
- if (!endpoint) return E_INVALIDARG;
+ if (!handle || !endpoint) return E_INVALIDARG;
if (channel->state != WS_CHANNEL_STATE_CREATED) return WS_E_INVALID_OPERATION;
return open_channel( channel, endpoint );
@@ -246,5 +248,6 @@ HRESULT WINAPI WsCloseChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx,
if (error) FIXME( "ignoring error parameter\n" );
if (ctx) FIXME( "ignoring ctx parameter\n" );
+ if (!handle) return E_INVALIDARG;
return close_channel( channel );
}
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index d85a151..f053c15 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -28,11 +28,11 @@ static void test_WsCreateChannel(void)
WS_CHANNEL_STATE state;
ULONG size, value;
- hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, NULL, NULL ) ;
+ hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
channel = NULL;
- hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL ) ;
+ hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( channel != NULL, "channel not set\n" );
@@ -64,14 +64,14 @@ static void test_WsOpenChannel(void)
WS_CHANNEL *channel;
WS_ENDPOINT_ADDRESS addr;
- hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL ) ;
+ hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsCloseChannel( channel, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
WsFreeChannel( channel );
- hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL ) ;
+ hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsOpenChannel( channel, NULL, NULL, NULL );
@@ -82,6 +82,9 @@ static void test_WsOpenChannel(void)
addr.headers = NULL;
addr.extensions = NULL;
addr.identity = NULL;
+ hr = WsOpenChannel( NULL, &addr, NULL, NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
hr = WsOpenChannel( channel, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -93,6 +96,10 @@ static void test_WsOpenChannel(void)
hr = WsCloseChannel( channel, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsCloseChannel( NULL, NULL, NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
WsFreeChannel( channel );
}
--
2.1.4
More information about the wine-patches
mailing list