summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_svcctl_nt.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-06-15 16:32:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:16 -0500
commit9b43bd3b62733992d06b6d8e602364efa816685c (patch)
treef82e430198b0bd553c58b04b30ebffcc0ea2e4a2 /source3/rpc_server/srv_svcctl_nt.c
parent5b678f7a8469e345a6b25fa19ea1a20fce939a21 (diff)
downloadsamba-9b43bd3b62733992d06b6d8e602364efa816685c.tar.gz
samba-9b43bd3b62733992d06b6d8e602364efa816685c.tar.bz2
samba-9b43bd3b62733992d06b6d8e602364efa816685c.zip
r7613: small changes to _svcctl_open_service() and create_open_service_handle() to prevent invalid service names from being accepted; printmig.exe now migrates drivers successfully
(This used to be commit dafb32c01f06c42f44aeb0d16681c5def4903244)
Diffstat (limited to 'source3/rpc_server/srv_svcctl_nt.c')
-rw-r--r--source3/rpc_server/srv_svcctl_nt.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c
index 230a222b8d..2685377772 100644
--- a/source3/rpc_server/srv_svcctl_nt.c
+++ b/source3/rpc_server/srv_svcctl_nt.c
@@ -171,6 +171,7 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle,
const char *service, uint32 access_granted )
{
SERVICE_INFO *info = NULL;
+ WERROR result = WERR_OK;
if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) )
return WERR_NOMEM;
@@ -186,16 +187,23 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle,
info->type = SVC_HANDLE_IS_SERVICE;
- if ( !(info->name = SMB_STRDUP( service )) ) {
- free_service_handle_info( info );
- WERR_NOMEM;
- }
-
/* lookup the SERVICE_CONTROL_OPS */
for ( i=0; svcctl_ops[i].name; i++ ) {
- if ( strequal( svcctl_ops[i].name, service ) )
+ if ( strequal( svcctl_ops[i].name, service ) ) {
info->ops = svcctl_ops[i].ops;
+ break;
+ }
+ }
+
+ if ( !svcctl_ops[i].name ) {
+ result = WERR_NO_SUCH_SERVICE;
+ goto done;
+ }
+
+ if ( !(info->name = SMB_STRDUP( service )) ) {
+ result = WERR_NOMEM;
+ goto done;
}
}
@@ -204,11 +212,15 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle,
/* store the SERVICE_INFO and create an open handle */
if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) {
- free_service_handle_info( info );
- return WERR_ACCESS_DENIED;
+ result = WERR_ACCESS_DENIED;
+ goto done;
}
- return WERR_OK;
+done:
+ if ( !W_ERROR_IS_OK(result) )
+ free_service_handle_info( info );
+
+ return result;
}
/********************************************************************