summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2013-04-09 15:15:53 +0300
committerArnon Gilboa <agilboa@redhat.com>2013-04-22 11:17:42 +0300
commit661e18fcf453cce08013928ef905d3d77b98f952 (patch)
tree46a77c1000fc84a1ed02252cb18c71b337d70fb7
parent0074ebcfb17cc9e68b390e06690bf76f9aa55729 (diff)
vdservice: add quotes to service path
for the case path contains a space, see CreateService() doc: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682450.aspx rhbz #918635
-rw-r--r--vdservice/vdservice.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 9134c4b..89e0dbb 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -170,12 +170,16 @@ bool VDService::install()
printf("OpenSCManager failed\n");
return false;
}
- TCHAR path[_MAX_PATH + 1];
- if (!GetModuleFileName(0, path, sizeof(path) / sizeof(path[0]))) {
+ TCHAR path[_MAX_PATH + 2];
+ DWORD len = GetModuleFileName(0, path + 1, _MAX_PATH);
+ if (len == 0 || len == _MAX_PATH) {
printf("GetModuleFileName failed\n");
CloseServiceHandle(service_control_manager);
return false;
}
+ // add quotes for the case path contains a space (see CreateService doc)
+ path[0] = path[len + 1] = TEXT('\"');
+ path[len + 2] = 0;
SC_HANDLE service = CreateService(service_control_manager, VD_SERVICE_NAME,
VD_SERVICE_DISPLAY_NAME, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,